View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default newbie ?: set variables, different shts, equal to each other

terry b.

I think what we have here is "mission creep"? <g
'--------------------------------------------------
Sub TestSomeMore()
Dim lngFirst As Long
Dim lngSecond As Long
Dim objSht1 As Excel.Worksheet
Dim objSht2 As Excel.Worksheet

Set objSht1 = Worksheets(1)
Set objSht2 = Worksheets(2)
lngSecond = 2

For lngFirst = 2 To 22 Step 4
objSht2.Cells(lngSecond, 2).Formula = "= " & objSht1.Name & "!" & _
objSht1.Cells(lngFirst, 2).Address
lngSecond = lngSecond + 1
Next 'lngFirst

End Sub
'-------------------------------------

Regards,
Jim Cone


"terry b" wrote in message
oups.com...
Hello, Jim
Hard-coding the formula into the destination cell is understood. BUT
this brings me back to why I wanted to use variables to refer to the
source- and destination-cells. Because the 1st link is [shts change
every time] B2 C2, next is B6 C3, next is B10 C4, next B14 C5,
and so on for well over 50 entries. So I needed to use variables to
refer to source & destination, so that I could use For...Next or
Do...Loop, and step the respective variables the necessary increments.
Do you see what I'm saying? If I specifically-coded the first
destination-cell "=TestSrc!B2", then how would I increment the cell
upward every time w/out having to write the specific-code 50+ different
times?
terry b.