Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy and paste to varying number of rows in Excel 1

Status
Not open for further replies.

kabushnell

Technical User
Jun 4, 2003
81
US
I am working on a macro and almost finished except I can't make one part work. I want to copy the value in cell B1 and copy to all rows in column B. I am trying to have it paste but the problem is the number of rows changes. I have used a code similar to the one below before with sucess but I can't seem to get this to work. Any thoughts?



Lastrow = ActiveSheet.Cell(1,1).CurrentRegion.Rows.Count+1
Range("B1").Select
Selection.Copy
With Range(Cells(Lastrow, "B"))
.PasteSpecial Paste:=xlPasteValues, Operation:=x1None, _
SkipBlanks:=False, transpose:=False
.AutoFill _
Destination:=Range("B1" & Lastrow), Type:=x1FillDefault
.Select
Selection.Clear
End With
 
try this


Lastrow = Cells(1, 1).End(xlDown).Row
Range("b1", "b" & Lastrow).FillDown


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top