Using Cells notation

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I have the following snippet of code:-

Code:
Selection.LinkedCell = "H" & x

However I have a loop where next time around the code will be:-

Code:
Selection.LinkedCell = "I" & x

and so on. How do I change the right side of the code and use the Cells notation to do what I want?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Maybe a 2nd counter? or using offset?

You would need to post your current code because it is hard to work with what you have, but probably something similiar to:

Code:
Selection.LinkedCell = cells(x,y).address(0,0)
Hope that helps.
 
Upvote 0
Selection.LinkedCell = Cells(X, icolumn).Address did the trick. Many thanks.
 
Upvote 0
Sorry to trouble you guys again, but I have another similar problem i.e.

Code:
                .Range("H" & x).Select
                .Range("H" & x).Value = True

I have the above code again running in a loop, where checkboxes are set to True or False i.e. H1, H2, H3, I1, I2, I3, J1, J2, J3, etc.
 
Upvote 0
You should be able to do the same as above. With that example you would have 2 loops, one for rows going 1 to 3 and one for columns going 8 through 10.

Expande the columns and rows loop numbers as needed.
 
Upvote 0
There is no need to Select (and it slows your code down). Try something like

Code:
Cells(X, icolumn).Value = True
 
Upvote 0
Thanks Peter, I didn't think it was that simple.
 
Upvote 0

Forum statistics

Threads
1,214,414
Messages
6,119,373
Members
448,888
Latest member
Arle8907

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