this has been killing me for the last week so I'm breaking down and asking for help! I have searched this exhaustively and haven't been able to crack it... Hoping someone can save me!
I need to copy a range selection from one sheet to another which should be an easy task, however the range is dynamic based on .Find results... I am able to pass all the required data into variables no problem but getting those string variables (both Column AND Row values) into the Range to copy keeps giving me the "Run Time Error 1004: PasteSpecial method of Range class failed ..."
Here is my full code currently:
Private Sub AutoFill_Week_One()
Dim Well_1 As Range
Dim GasComp As Range
Dim gRow As Integer
Dim lRow As Integer
Dim GsRow As String
Dim LsRow As String
Dim GsDate As String
Dim LsDate As String
Dim GsRngS As String
Dim GsRngE As String
Dim LsRngS As String
Dim LsRngE As String
Dim GsComp As String
Dim LsComp As String
With Sheets("CSV Import")
Set Well_1 = Range("O1:O200").Find("102040307310W600")
Well_1.Activate
gRow = ActiveCell.Row
GsRow = "A" & CStr(gRow)
If Range(GsRow).value = "G" And Well_1.value = "102040307310W600" Then
GsDate = "E" & CStr(gRow)
MsgBox GsDate
Range(GsDate).Copy
Sheets("Week One").Range("F31").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
GsRngS = "T" & CStr(gRow)
GsRngE = "AG" & CStr(gRow)
GsComp = GsRngS & ":" & GsRngE
MsgBox GsComp
Set GasComp = .Range(GsComp)
GasComp.Copy
Sheets("Week One").Range("F33:F46").PasteSpecial _
Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Set Well_1 = Range("O1:O200").FindNext(Well_1)
Well_1.Activate
lRow = ActiveCell.Row
LsRow = "A" & CStr(lRow)
If Range(LsRow).value = "L" And Well_1.value = "102040307310W600" Then
MsgBox "Liquid"
End If
End With
End Sub
Sorry, I know this code is kinda hacked together but I've tried arrays, .offset and every other thing I could think of with no luck...
Any thoughts?
Thanks so much in advance!
Hey BigBen that transfer is working! But I can't get the syntax to transfer them to a vertical range (F33:F46) they are only transferring horizontally! What am I missing?
With ThisWorkbook.Sheets("CSV Import").Range(GsComp)
Sheets("Week One").Cells(33, 6).End(xlUp).Cells(46, 6).Resize(.Rows.Count, .Columns.Count) = .value
End With