Thread: Blank cell
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
AlanW AlanW is offline
external usenet poster
 
Posts: 29
Default Blank cell


Hello JLGWhiz,

You did what I intend to do, but can do me one more favour. Please show me
how to Move the data in last two cells just before the blank cell.

Thanks so much

"JLGWhiz" 來函:

You will need to find the last cell in the row with data for each row as you
attempt to move or copy.

Sub cpyNTLcell()
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
rng = ActiveSheet.Range("A2:A" & lr)
For i = 2 To lr
ActiveSheet.Cells(i, Columns.Count).End(xlToLeft).Copy _
Sheets(2).Range("A" & i)
Next
End Sub

"AlanW" wrote:

I have a worksheet with many rows, however, each of which is ended in
different column. For example, Row 1 ends in Column P, Row 2 ends in Column
C, Row 3 ends in Column E and so on. How can I move or copy the data in the
cell just before the blank cell using VB. Could someone help.

Thanks