Hi,
I am trying to write a vba code which copies stuff from a given set of ranges and pastes them in other ranges
The code is as follows:
But I am getting an error at 're' creation saying error 91: object variable or with variable not set.
Kindly help me as to what is wrong with the code?
I am trying to write a vba code which copies stuff from a given set of ranges and pastes them in other ranges
The code is as follows:
Code:
Option Explicit
Sub finding()
Dim i, j As Integer
Dim re As Range
Dim rw As Range
Dim range1, range2, range3, range4, range5, range6, range7, range8 As Range
Dim rangww1, rangww2, rangww3, rangww4, rangww5, rangww6, rangww7, rangww8 As Range
Set range1 = Sheet2.Range("A1:A100").Find(What:="Baseline", LookIn:=xlValues)
Set range2 = Sheet2.Range("A1:A100").Find(What:="1Y3M", LookIn:=xlValues)
Set range3 = Sheet2.Range("A1:A100").Find(What:="1Y6M", LookIn:=xlValues)
Set range4 = Sheet2.Range("A1:A100").Find(What:="1Y9M", LookIn:=xlValues)
Set range5 = Sheet2.Range("A1:A100").Find(What:="1Y12M", LookIn:=xlValues)
Set range6 = Sheet2.Range("A1:A100").Find(What:="2Y3M", LookIn:=xlValues)
Set range7 = Sheet2.Range("A1:A100").Find(What:="2Y6M", LookIn:=xlValues)
Set range8 = Sheet2.Range("A1:A100").Find(What:="2Y9M", LookIn:=xlValues)
rangww1 = Sheet1.Range("E10")
rangww2 = Sheet1.Range("E43")
rangww3 = Sheet1.Range("E76")
rangww4 = Sheet1.Range("E109")
rangww5 = Sheet1.Range("E142")
rangww6 = Sheet1.Range("E175")
rangww7 = Sheet1.Range("E208")
For j = 1 To 8
re = "range" & j
rw = "rangww" & j
If Not re Is Nothing Then
For i = 0 To 3
Sheet2.Activate
Range(re.Offset(i, 2), re.Offset(i, 7)).copy
Sheet1.Activate
Range("rw").Offset(i * 7, 3).Activate
Selection.PasteSpecial Paste:=xlPasteAll, Transpose:=True
Next i
End If
Next j
End Sub
But I am getting an error at 're' creation saying error 91: object variable or with variable not set.
Kindly help me as to what is wrong with the code?