Extract some data from one sheet to another sheet under certain criteria using VBA (1 Viewer)

mstres

Registered User.
Local time
Today, 08:27
Joined
Mar 18, 2009
Messages
24
I am using Excel 2003
I want to copy data from one worksheet to another worksheet in the same workbook under certain criteria and some validations using VBA code.
I would like to have a button on first wokrsheet to copy data
First column must be a header
I have a spreadsheet with say 6 columns and 50 rows (maybe more).
For example if 4th column is not a number(currency) do not copy this row and validation if 2nd row is empty or null populate with 0 as default.
If any body have any examples
Thank you,
Mike
 
Last edited:

Brianwarnock

Retired
Local time
Today, 16:27
Joined
Jun 2, 2003
Messages
12,701
not really sure of your requirements, the code below copies the total rows out of a set of rows from sheet1 to sheet2, it may help to get you started.

Brian

Code:
Sub copytotalrows()

Dim x As Integer
x = 1

Do

If Sheets("sheet1").Cells(x, 1) = "total" Then 'Caps sensitive
Sheets("sheet1").Cells(x, 1).EntireRow.Copy
Sheets("sheet2").Select
With ActiveSheet
.Cells(.Range("A65536").End(xlUp).Row + 1, 1).Select
End With
Selection.PasteSpecial Paste:=xlPasteValues
End If

x = x + 1
Loop Until Sheets("sheet1").Cells(x, 2) = ""

Application.CutCopyMode = False

End Sub
 

mstres

Registered User.
Local time
Today, 08:27
Joined
Mar 18, 2009
Messages
24
Brian,
Thank you very much, it was very good for start.
Mike
 

Brianwarnock

Retired
Local time
Today, 16:27
Joined
Jun 2, 2003
Messages
12,701
Happy to help, can I assume that all is well now?

Brian
 

Users who are viewing this thread

Top Bottom