Offset issue

G

Guest

I inherited a list of field heading that get built by hard coding as follows:
Range("A1").FormulaR1C1 = "Filed 1â€
Range("B1").FormulaR1C1 = "Filed 2â€

How can I increment for the start point of cell A1 omitting hard coded ranges?
I’m currently messing around with offset…
Appreciatively,
Arturo
 
J

Jim Cone

Maybe...

'Select some cells
Sub MakeTitles()
Dim rCell As Range
For Each rCell In Application.Intersect(Selection.EntireColumn, Rows(1)).Cells
rCell.Value = "Filed " & rCell.Column
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Arturo" <[email protected]>
wrote in message
I inherited a list of field heading that get built by hard coding as follows:
Range("A1").FormulaR1C1 = "Filed 1â€
Range("B1").FormulaR1C1 = "Filed 2â€

How can I increment for the start point of cell A1 omitting hard coded ranges?
I’m currently messing around with offset…
Appreciatively,
Arturo
 
G

Guest

I stated the issue incorrectly.
What I've got working now is:
ActiveCell.Offset(0, 1).Select
ActiveCell = "ABC"
ActiveCell.Offset(0, 1).Select
ActiveCell = "123"
and so on...
All the differing field headings reside in code. Is there a cleaner way to
increment in the same line: ActiveCell.Offset(0, 1) and have it equal "XYZ",
then the line of code would be ActiveCell.Offset(0, 1) and have it equal
"LOB" and so on working from a long hard coded list. I hope this makes more
sence...
 
J

Jim Cone

'Select some cells
Sub MakeTitles_R1()
Dim Ndx As Long
Dim rHeadings As Range
Dim vArray As Variant

vArray = Array("Aqua", "Black", " Blue ", "Blue-Gray", " Bright Green ", _
"Brown", " Coral", " Dark Blue", " Dark Green")
Set rHeadings = Application.Intersect(Selection.EntireColumn, Rows(1)).Cells

For Ndx = 1 To Application.Min(rHeadings.Count, UBound(vArray) + 1)
rHeadings(Ndx).Value = vArray(Ndx - 1)
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Arturo" <[email protected]>
wrote in message
I stated the issue incorrectly.
What I've got working now is:
ActiveCell.Offset(0, 1).Select
ActiveCell = "ABC"
ActiveCell.Offset(0, 1).Select
ActiveCell = "123"
and so on...
All the differing field headings reside in code. Is there a cleaner way to
increment in the same line: ActiveCell.Offset(0, 1) and have it equal "XYZ",
then the line of code would be ActiveCell.Offset(0, 1) and have it equal
"LOB" and so on working from a long hard coded list. I hope this makes more
sence...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top