vba code to reference a cell within a range, based on another cell

pingpong777

New Member
Joined
Apr 6, 2015
Messages
42
i have the following copy/paste loop:

Do Until Range("c475").Value = "OK"


Range("c473").Select
Selection.Copy
Range("c280").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


Loop



where it pastes to cell C280, i would like to paste to a cell within the range E280:Y280, referring to a cell named "COLUMN" for the number of columns over. so if COLUMN=3, i want to paste to G280.


i saw elsewhere that i could use something like:

Range("E280:Y280") ("COLUMN").Select

for that line, but i'm wondering if this is the most efficient.

thanks for having a look, and thanks for your help!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Try
Code:
Range("c473").Copy
Range("E280:Y280").Cells(1, Range("COLUMN").Value).PasteSpecial Paste:=xlPasteValues

But please get out of the habit of using words like COLUMN for names and variables that Excel uses as it will only give you grief.
 
Upvote 0
thanks! i actually am using a different name for that cell. i have no good explanation for why i didn't just use the actual cell name in my question on here.

thanks again!


pingpong777
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,715
Members
448,985
Latest member
chocbudda

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
Back
Top