-
Make VBA Cell a Formula
I have some code that finds the value based upon a counter, such as:
Cells(10, 10) = Cells(CounterA, ColumnA)
...Lets say CounterA=1
I want Cells(10,10) to actually be "=A1", rather than whatever value was contained when it was run. Any ideas? For some reason, I thought I did this before, but can not find the code to do it.
-
[VBA] Dim CounterA As Long, ColumnA As String
ColumnA = "A"
CounterA = 1
Cells(10, 10).Formula = "=" & ColumnA & CounterA[/VBA]
-
Is there a more "direct" way? What can one do if ColumnA is not a constant value (but rather obtained from a loop).
Perhaps I gave an oversimplified example. That said, I may still be able to get this to do what I want "as is".
-
Try:
[VBA]Sub example()
Const CounterA As Long = 1
Const ColumnA As Long = 1
Cells(10, 10).Formula = "=" & Cells(CounterA, ColumnA).Address(0, 0, , -1)
End Sub[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules