Hello All,
I am trying to get data from a table into various cells in another worksheet. I am doing this by selecting a facility from a drop down list in V16 of the sheet I want the data to go to.
I then click a button with the following code in it:
Private Sub CommandButton9_Click()
Dim Datasheet As Worksheet
Dim EQUFACsheet As Worksheet
Dim Facility As String
Dim finalrow As Integer
Dim i As Integer
Set Datasheet = Sheets("Data")
Set EQUFACsheet = Sheets("EQU FAC input sheet")
Facility = EQUFACsheet.Range("V16").Value
EQUFACsheet.Range("B8").MergeArea.ClearContents
EQUFACsheet.Range("H8").MergeArea.ClearContents
Datasheet.Select
finalrow = Datasheet.Range("B200").End(xlUp).row
For i = 6 To finalrow
If Cells(i, 2) = Facility Then
Range(Cells(i, 2)).Copy
EQUFACsheet.Select
Range("B8").PasteSpecial
Datasheet.Select
End If
Next i
EQUFACsheet.Select
Range("V16").Select
End Sub
It doesn't throw up any errors but when I look at the code execution I can see that it runs through each row in the table but doesn't match the facility, it simply stops there?
The destination for the lookup info is B8 in the EQUFACsheet
Any ideas?
Bookmarks