hello people,
I'm only starting with VBA, and I hit the wall a bit. Can anybody help me?
Recently I was trying to create dynamic spreadsheet for expenses calculation which would allow me to see data in separate tabs. For instance I have tab for all data for entire year and I would like to copy lines with expenses in January to January tab and so on. I have managed to run code witch does copy entire line to another tab but my first problem is that the code is not dynamic also how can I add more syntaxes to the code so it would work for all months?
See my code below:
< Use Code Tags >
I'm only starting with VBA, and I hit the wall a bit. Can anybody help me?
Recently I was trying to create dynamic spreadsheet for expenses calculation which would allow me to see data in separate tabs. For instance I have tab for all data for entire year and I would like to copy lines with expenses in January to January tab and so on. I have managed to run code witch does copy entire line to another tab but my first problem is that the code is not dynamic also how can I add more syntaxes to the code so it would work for all months?
See my code below:
Code:
Sub CopyYes()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
' Change worksheet designations as needed
Set Source = ActiveWorkbook.Worksheets("Dane")
Set Target = ActiveWorkbook.Worksheets("January")
j = 2 ' Start copying to row 1 in target sheet
For Each c In Source.Range("b2:b1000") ' Do 1000 rows
If c = "January" Then
Source.Rows(c.Row).Copy Target.Rows(j)
j = j + 1
End If
Next c
End Sub
Last edited by a moderator: