Bruno125sx
New Member
Hi There,
Please, anyone can help me with a VBA code.
Purpose is : Finding the variable date form "Sheet2" "F13" into my Row 13 "sheet 7" (Col F to HP)
get the location Cells(Y, x) so i can from this Cell (Y, x) copy and past some selected data do "sheet2".
This is a part of a macro attached to a button.
So far i did this but i guess im a bit far to get what i want (
i hope you guys can understand what i hope to achieve. if there is a simple way i would be glad to hear.
thanks a lot.
Please, anyone can help me with a VBA code.
Purpose is : Finding the variable date form "Sheet2" "F13" into my Row 13 "sheet 7" (Col F to HP)
get the location Cells(Y, x) so i can from this Cell (Y, x) copy and past some selected data do "sheet2".
This is a part of a macro attached to a button.
So far i did this but i guess im a bit far to get what i want (
Code:
Sub CopyTimeLine()
Dim ws As Worksheet
Dim ws7 As Worksheet
Dim rng As Range
Dim targetDate As Range
'change sheet1 to suit
Set ws2 = ThisWorkbook.Worksheets("Sheet2")
Set ws7 = ThisWorkbook.Worksheets("Sheet7")
'change address of your cell with target date
Set targetDate = ws2.Range("F13")
'tries to find target date in first row
Set rng = ws7.Range("13:13").Find(What:=targetDate, LookAt:=xlWhole, MatchCase:=False)
If rng Is Nothing Then
'if nothing found - search for last non empty column
MsgBox "not Found"
MatchCase:=False, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
Else
Get the found Cells(Y, x) to include in the following.
'Sheets("7").Select
'Range(Cells(Y, x+1), Cells(Cells(14, 6) + 50, Cells(14, 6) + 59)).Select
'Selection.Copy
'Sheets("2").Select
'Range("F14:G14").Select
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
'True, Transpose:=False
End If
End Sub
i hope you guys can understand what i hope to achieve. if there is a simple way i would be glad to hear.
thanks a lot.
Last edited by a moderator: