View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Variables in a cell reference

Sub Ne()
Dim y As Integer
Dim x As Integer
Cells(4, 10) = "=COUNTA(A:A,"" * "")-1"
y = Cells(4, 10)
For x = 1 To y
Cells(x, 1).Value = Range("B1").Value & " " & Range("C1").Value
Next x
End Sub

You want the same value in every cell?

maybe
cells(x,1).Value = Cells(x,2).Value & " " & cells(x,3).Value

--
Regards,
Tom Ogilvy


"Carpe Diem" wrote:

I would like to know how I could combine cells with variables if possible.
Something similar to the Selection.Value Selection.Value = B1& C1
line in the code below but which operates like (x,2)&"" ""&(x,3) so I can
get the appropriate cells to add together with a space in between.

I am likely mixing syntax as I am unfamiliar with VB.
Sub Ne()
Dim y As Integer
Dim x As Integer
Cells(4, 10) = "=COUNTA(A:A,"" * "")-1"
y = Cells(4, 10)
For x = 1 To y
Cells(x, 1).Select
Selection.Value = B1& C1
Next x
End Sub