Indranil_Guha
New Member
Dear All,
i am trying to build a macro that will copy a range of cells and then it will find a specific date in a table and add the copied cells with the existing values in the column.
i have created the macro but it is working strangely.
i mean when i am trying it step by step (using F8) it is working as desired but when i am playing the macro, it is not working. the coding is as under.
could any one please help me to identify the fault. any help will be appreciated.
Sub test()
Dim ws As Worksheet
Dim rng As Range
Dim targetDate As Range
Sheets("Sale").Select
Range("APK5:APK30").Select
Selection.Copy
Set ws = ThisWorkbook.Worksheets("Sale")
Set targetDate = ws.Range("APK3")
Set rng = ws.Range("3:3").Find(What:=targetDate, LookAt:=xlWhole, MatchCase:=False)
rng.Offset(2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _
:=False, Transpose:=False
End Sub
i am trying to build a macro that will copy a range of cells and then it will find a specific date in a table and add the copied cells with the existing values in the column.
i have created the macro but it is working strangely.
i mean when i am trying it step by step (using F8) it is working as desired but when i am playing the macro, it is not working. the coding is as under.
could any one please help me to identify the fault. any help will be appreciated.
Sub test()
Dim ws As Worksheet
Dim rng As Range
Dim targetDate As Range
Sheets("Sale").Select
Range("APK5:APK30").Select
Selection.Copy
Set ws = ThisWorkbook.Worksheets("Sale")
Set targetDate = ws.Range("APK3")
Set rng = ws.Range("3:3").Find(What:=targetDate, LookAt:=xlWhole, MatchCase:=False)
rng.Offset(2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _
:=False, Transpose:=False
End Sub