String input into active cell

cmeier7

Board Regular
Joined
Jul 23, 2009
Messages
64
Hey all,

This should be a quickie compared to some of the problems you're all dealing with. I am trying to input a text string disguised as a formula into an active cell. I have code:

Code:
Dim n As String, a As String, r As Integer, b As Inte
n = "Test_STEEL 5in" 
a = "C"
r = ActiveCell.Row
b = r - 1
 
ActiveCell.Value = "='" & n & "'!" & a & "" & b & ""

In this case, I want the below string in the active (selected) cell when the program runs.

Code:
='Test_STEEL 5in'!C8

I have also tried .Text .String and a couple others but those are giving me additional errors. Why isn't it taking? Thanks in advance!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Why don't you try formatting your cells as text? Select your columns or rows whatever, right click, choose "format cells", > text. Then run your macro.
 
Upvote 0
How about this?

Code:
Sub test()
With ActiveCell
    .NumberFormat = "@"
    .Formula = "='Test_STEEL 5in'!" & Cells(.Row - 1, 3).Address(0, 0)
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,917
Members
452,949
Latest member
beartooth91

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