Reg. Strings in for loops

jonastjader

New Member
Joined
Dec 9, 2013
Messages
12
Hi,
I want to make the string variable j go through different strings (to assign different Cells columns such as "A" or "B"). With integers it is easy:
Dim i As Integer
For i = 1 To 24

But how can I do a similair thing with strings? Or maybe assign so that 1,2,3 will be converted to A,B,C inside the for loop?
Dim j As String
For j = "A" To "C"
This does not seem to work...

Best,
Jonas
 

Some videos you may like

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,680
Office Version
  1. 2010
Platform
  1. Windows
Hi,
I want to make the string variable j go through different strings (to assign different Cells columns such as "A" or "B"). With integers it is easy:
Dim i As Integer
For i = 1 To 24

But how can I do a similair thing with strings? Or maybe assign so that 1,2,3 will be converted to A,B,C inside the for loop?
Dim j As String
For j = "A" To "C"
This does not seem to work...

Using an modification of the method I posted to your other thread (where you asked this question for the numbers 1 thru 24) here...

http://www.mrexcel.com/forum/excel-...values-help-integer-variable.html#post3682418

this is how I would do it...

Code:
Sub ForLoop3()
  Range("A1:A24") = Evaluate("IF(ROW(),CHAR(64+ROW(1:24)))")
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,491
Messages
5,596,466
Members
414,069
Latest member
StudExcel

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
Top