View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Request for VB to do something simple (insert text in a column of

Also fills blank cells which OP did not want.


Gord Dibben MS Excel MVP

On Tue, 20 Nov 2007 01:56:00 -0800, Gary''s Student
wrote:

Hi David:

Withour VBA, in B2 enter:
="XYZ" & A2 and copy down (assumes A1 is a header cell)

With VBA, YOU select a part of ANY column and run:

Sub david1()
For Each r In Selection
r.Offset(0, 1).Value = "XYZ" & r.Value
Next
End Sub

david1 will fill the adjact cells


With VBA, run david2:

Sub david2()
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To n
Cells(i, 2).Value = "XYZ" & Cells(i, 1).Value
Next
End Sub

david2 does not require you to Select the cells. It works on column A and
figures how far down to go.