Macro to link cells

Candidont

New Member
Joined
Mar 21, 2018
Messages
3
Something's not right and I expect the x and y won't change in the quotations. Any ideas?

Sub linkMergedCells()
Dim x As Integer
Dim n As Integer
n = 3
x = 6
Do While x > 0
For y = 1 To 6
Worksheets("Sheet1").Cells ("A" & n)
.Formula = "=Sheet3!(x,y)"
n = n + 2
Next y
x = x - 1
Loop
End Sub

Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Anything between double-quotes is literal text. x and y need to be outside of the quotes.
So you need to break it up into literal text and variables concatenate together.
But (x,y) is not a valid range reference anyway. Maybe this is what you mean?
Code:
[B]Worksheets("Sheet1").Cells(n, "A").Formula = "=Sheet3!" & Cells(x,y).Address[/B]
If that isn't it, you are going to need to explain exactly what it is that you are trying to do, so we are guessing based on errant code.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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