Production Planner
New Member
- Joined
- Apr 19, 2011
- Messages
- 15
Hi Everyone,
I am having some issues when running the macro I have put in place to look up a date within a range and copy / paste the data in the column as a value once found (this is due to the data being looked up via a formula - this is to be done on 3 different worksheets.
For some reason it is not finding the date.
The Date value is on Worksheet "Weekly Report Input Values" Cell K2
The Date to find is located withing cells "e2:gg2" on the other 3 sheets (FV04 , FV05 & AWAF Data Input Sheets)
The Data to copy and paste as values below the found date on the 3 sheets above is located in rows 5 through 51
I'm sure there are other errors to the code below but finding a date match is the first step.
Here is the code below.
There is further code beyond this that creates a hard value copy of the workbook for distribution.
Any help on getting this working would be appreciated.
Cheers Guys.
I am having some issues when running the macro I have put in place to look up a date within a range and copy / paste the data in the column as a value once found (this is due to the data being looked up via a formula - this is to be done on 3 different worksheets.
For some reason it is not finding the date.
The Date value is on Worksheet "Weekly Report Input Values" Cell K2
The Date to find is located withing cells "e2:gg2" on the other 3 sheets (FV04 , FV05 & AWAF Data Input Sheets)
The Data to copy and paste as values below the found date on the 3 sheets above is located in rows 5 through 51
I'm sure there are other errors to the code below but finding a date match is the first step.
Here is the code below.
Code:
Dim rFndCell As Range
Dim strData As String
Dim stFnd As String
Dim fCol As Integer
Dim sh As Worksheet
Dim ws As Worksheet
Dim rFndCell1 As Range
Dim strData1 As String
Dim stFnd1 As String
Dim fCol1 As Integer
Dim sh1 As Worksheet
Dim ws1 As Worksheet
Dim rFndCell2 As Range
Dim strData2 As String
Dim stFnd2 As String
Dim fCol2 As Integer
Dim sh2 As Worksheet
Dim ws2 As Worksheet
Set ws = Sheets("Weekly Report Input Values")
Set sh = Sheets("FV 04 Data Input Sheet")
stFnd = ws.Range("K2").Value
With sh
Set rFndCell = sh.Range("e2:gg2").Find(stFnd, LookIn:=xlValues)
If Not rFndCell Is Nothing Then
fCol = rFndCell.Column
sh.Range("5:51").Copy
sh.Cells(5, fCol).PasteSpecial xlPasteValues
Else 'Can't find the item
MsgBox "Date Not Found"
End If
End With
Set ws1 = Sheets("Weekly Report Input Values")
Set sh1 = Sheets("FV 05 Data Input Sheet")
stFnd1 = ws1.Range("K2").Value
With sh1
Set rFndCell1 = sh1.Range("e2:gg2").Find(stFnd1, LookIn:=xlValues)
If Not rFndCell1 Is Nothing Then
fCol1 = rFndCell1.Column
sh1.Range("5:51").Copy
sh1.Cells(5, fCol1).PasteSpecial xlPasteValues
Else 'Can't find the item
MsgBox "Date Not Found"
End If
End With
Set ws2 = Sheets("Weekly Report Input Values")
Set sh2 = Sheets("AWAF Data Input Sheet")
stFnd2 = ws2.Range("K2").Value
With sh2
Set rFndCell2 = sh2.Range("e2:gg2").Find(stFnd2, LookIn:=xlValues)
If Not rFndCell2 Is Nothing Then
fCol2 = rFndCell2.Column
sh2.Range("5:51").Copy
sh2.Cells(5, fCol2).PasteSpecial xlPasteValues
Else 'Can't find the item
MsgBox "Date Not Found"
End If
End With
There is further code beyond this that creates a hard value copy of the workbook for distribution.
Any help on getting this working would be appreciated.
Cheers Guys.