cstr() works but loop still posts as value

KG Old Wolf

Board Regular
Joined
Sep 20, 2009
Messages
65
All,

This seems so simple and it is not (at least to me).

I have a loop that reads a column of cells contains text (i.e 3640F, 88190, 88172pc). I need to just use the 5 leftmost characters and post them to another cell in the same row.

The Cstr() works but the result being posted in the related cell posts as a value when the 5 characters are number... i.e. the above 88190 and 88172 post as numbers. I need them to be text.

the loop is simple:

For lp_ctr_1 = 20 To 50 Step 1
'
varMisc = CStr(Left(Cells(lp_ctr_1, 1), 5))
Cells(lp_ctr_1, 3) = varMisc
'
Next


varMisc correctly stores a five digit number as "88190" but the receiving cell stores it as a value 88190

I cannot seem to get the receiving cell to store as text.... this is basic so it has to be me.... all help is greatly appreciated!

-kg-
 
Last edited:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Maybe

Code:
With Cells(lp_ctr_1, 3)
    .NumberFormat = "@"
    .Value = varMisc
End With
 
Upvote 0
Perfect solution.... and I learned two things in the process (I am self-taught and find this board to be an amazing resource)

Thanks so much for your help,
Ken
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,146
Members
452,547
Latest member
Schilling

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