How To: Macro Command To Reference Populated Cells Only

T

TJM

Is there a macro command line that I can use that will referenc
populated cells only?

My example: I have Column A populated. This may be cells A1 - A
(meaning A? = will vary). In column B, I have a macro command to ad
"@site.com".

What I want to be able to do is this: run my macro and have it add th
"@site.com" only those populated cells in column A.

Right now, I select cell B1 and type the formula "=A1&"@site.com".
then manually copy and paste this formula to the remain cells in colum
B to the point where the cells are populated in column A. I'd like t
be able to automate this process via a macro.

Thanks!

TJ
 
D

Dave Peterson

option explicit
sub testme01()

dim wks as worksheet

set wks = activesheet
with wks
with .range("a1",.cells(.rows.count,"A").end(xlup)).offset(0,1)
.formula = "=a1&""@site.com"""
.value = .value
end with
end with
end sub

This'll do it from A1 to the last used cell in column A.
 
Top