MagicMrMiyagi
New Member
- Joined
- Sep 24, 2010
- Messages
- 18
Good morning everybody,
I am trying to create a macro that copies data from one worksheet into another. So far I am using code like this:
This works as long as I have only two conditions, stated by may variables.
Now I am having a problem trying to copy different data, depending on the actual quarter.
For example column A contains Data for Q1 (January,February, March), column B contains Data for Q2 (April, May, June) and so on.
The actual month is on the same sheet where I am getting the data from in cell "BD2".
So i figured it has to be something like (careful wrong and silly code incoming )
Obviously that bit of code is not working but I hope that it helps to see what I am trying to do.
I hope that it didn't get too confusing and that someone can help me.
Thanks in advance
Fred
I am trying to create a macro that copies data from one worksheet into another. So far I am using code like this:
Code:
Sub LogCost()
Dim sPlant As String
Dim sBU As String
sPlant = Range("q5").Text
sBU = "Green"
Application.ScreenUpdating = False
Windows("Gifts.xlsm").Activate
With Workbooks("Gifts.xlsm").Sheets("Today")
For i = 1 To 400
'YTDActual
If .Range("I" & i) = sPlant And .Range("G" & i) = sBU Then
.Range("C" & i).Copy
actual = 7
Workbooks("Action.xlsm").Sheets("Action_Today").Activate
Cells(actual, "N").End(xlToLeft).Offset(0, 1).PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End If
Next i
End with
End sub
This works as long as I have only two conditions, stated by may variables.
Now I am having a problem trying to copy different data, depending on the actual quarter.
For example column A contains Data for Q1 (January,February, March), column B contains Data for Q2 (April, May, June) and so on.
The actual month is on the same sheet where I am getting the data from in cell "BD2".
So i figured it has to be something like (careful wrong and silly code incoming )
Code:
if .cells("BD2") = "01.01.2011" or cells.("BD2") = "01.02.2011" or cells ("BD2") = "01.03.2011" Then
.Range("A" & i).Copy
end if
if .cells("BD2") = "01.04.2011" or cells.("BD2") = "01.05.2011" or cells ("BD2") = "01.06.2011" Then
.Range("B" & i).Copy
Obviously that bit of code is not working but I hope that it helps to see what I am trying to do.
I hope that it didn't get too confusing and that someone can help me.
Thanks in advance
Fred
Last edited: