What have I got wrong? (Macro),,,

S

ste mac

Hello to all, I have almost got this thing working, my problem is
that it will not 'select' the correct sheet before looking for the
'idNumber'.. and l just don't know why... I have been messing
around with it for a couple of days... I think the rest of the
code will work once it finds the idNumber on the rightsheet..

Thanks for any help you can give...seeya ste


sub getdepthvalue()

Dim SheetName As String
Dim sheetNumber As Long
Dim rightSheet As Long
Dim idNumber As String
Dim activeid As String
Dim xlrow As Long
Dim scennumber As Variant
Dim thedepth As Long
Dim copyrange As Range

Sheets("Live History").Select
Sheets("Live History").Range("N1").End(xlDown).Select
ActiveCell.Offset(0, 5).Select
idNumber = ActiveCell.Value

For sheetNumber = 1 To 56

xlrow = 3

SheetName = "S" & Format(sheetNumber, "##0")
Sheets(SheetName).Select

rightSheet = Sheets("Live History").Range("H1").End(xlDown).Value
scennumber = ActiveSheet.Cells(3, 2).Value

If rightSheet = scennumber Then
ActiveSheet.Range("A3").Select
End If

Do Until ActiveCell.Value = idNumber
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Value = idNumber Then
ActiveCell.Offset(0, 9).Select
End If
ActiveCell.Copy
Set copyrange = ActiveCell
Sheets("Live History").Select
ActiveSheet.Range("P1").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlPasteValues

End

Next
End

importdata
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top