View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Peter Peter is offline
external usenet poster
 
Posts: 349
Default finding the next empty column

hi joel,
the first version of your suggestion was good but it put the column after
the last full cell in the first col. its not quite what i wanted but its
going to come in handy in the future for these cases.
many many thanks for helping me.

--
Peter


"Joel" wrote:

Small change

Sub test()
With Sheets("Sheet1")
Sht1LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Sht2LastCol = _
Sheets("Sheet2").Cells(1,Columns.Count).End(xltole ft).Row
Sh2NewCol = Sht2LastCol + 1
.Range("A1:A" & Sht1LastRow).Copy _
Destination:=Sheets("Sheet2").Cells(1,Sh2NewCol)
End With
End Sub


"Joel" wrote:

Sub test()
With Sheets("Sheet1")
Sht1LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
Sht2LastRow = _
Sheets("Sheet2").Range("A" & .Rows.Count).End(xlUp).Row
.Range("A1:A" & Sht1LastRow).Copy _
Destination:=Sheets("Sheet2").Range("A" & Sht2LastRow)
End With
End Sub

"Peter" wrote:

i am new to vba and am keen to learn from others with more experience.

this came from this ms discussion groups. it copies a range in col 1 of
sheet 1 to col 1 of sheet2
Sub test()
With Sheets("Sheet1")
.Range("A1:A" & .Range( _
"A" & .Rows.Count).End(xlUp).Row).Copy Sheets("Sheet2").Range("A1")
End With
End Sub

i am happy to use this but i would like it to be a bit more sophisticated in
choosing where in sheet 2 it pastes.

i would like the destination in sheet 2 to be "..in the colum immediately to
the right of the last colum that has data in it".

could someone pls start me off with a bit of code pls.

thanking you in advance.
--
Peter