Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using variable to select column I have a variable called \"Tier\" which ranges f

ID: 3571036 • Letter: U

Question

Using variable to select column

I have a variable called "Tier" which ranges from 1 to any last value. I want column Z in sheet named "Slice#" (# is the Tier number of that sheet) and paste this in sheet "Table" where it is placed in column number based on what this Tier value is (Tier numbers are just integers).

I was going to use the code below but I am not sure if the bold part is the correct syntax or format:

' first active sheet is current Slice# sheet that the programme is currently on

ActiveSheet.Range(

Explanation / Answer

Hi..

Hi,

You can do it without selecting anything like this:-

Sub somesub()
Dim increment As Long
Dim tier As Long
increment = 10
tier = 1
Sheets("Slice" & tier).Range("Y1:Y" & increment).Copy

Sheets("Table").Columns(tier).PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

End Sub