Select sheet from offset of a variable

Lidget

New Member
Joined
Apr 14, 2021
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Hi.
I have a book with multiple sheets, 6 are dumps of source data and 50 are worksheets I want to populate from the source.
I have a control sheet and in column c are the 50 worksheets and column d contains the related source sheet name.

I have the following code (kindly suggested here) to clear old info from the worksheets

Sub Lidget()
Dim Cl As Range
Dim UsdRws As Long

With Sheets("Control")
For Each Cl In .Range("C4", .Range("C" & Rows.Count).End(xlUp))
If Cl.Value <> "" Then
If Evaluate("isref('" & Cl.Value & "'!A1)") Then
Sheets(Cl.Value).Range("A1:F10").clearcontents

End If
End If
Next Cl
End With
End Sub

Now I'm trying to repeat this but with
Sheets(Cl.offset(0, 1).Value).Range("A1:F10").Copy
Sheets(Cl.Value).Range("A1:F10").paste

But I'm getting "object doesn't support this property or method"
I've tried making the offset of c1 a variable but I'm even worse with variables
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,161
Office Version
  1. 2016
Platform
  1. Windows
Why not try create a variable to replace:
A= Cl.Offset(0,1).Value
then substitute
Sheets(A).Range("A1:F10").Copy

I guess you've tried. Not read properly
 

Lidget

New Member
Joined
Apr 14, 2021
Messages
8
Office Version
  1. 2013
Platform
  1. Windows
Why not try create a variable to replace:
A= Cl.Offset(0,1).Value
then substitute
Sheets(A).Range("A1:F10").Copy

I guess you've tried. Not read properly
Yeah I finally got around it with the variables. Wants dim'ing as worksheet >_<
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,611
Office Version
  1. 365
Platform
  1. Windows
You were getting the error because this line Sheets(Cl.Value).Range("A1:F10").paste should be Sheets(Cl.Value).Range("A1:F10").PasteSpecial
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,666
Messages
5,637,649
Members
416,979
Latest member
CapeCon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top