PC Review


Reply
 
 
AlanW
Guest
Posts: n/a
 
      27th Jun 2009

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
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      27th Jun 2009

Try

Activesheet.Usedrange.select

To copy from one sheet to another
Sheets("Sheet1").usedrange.copy Sheets("Sheet2").Range("A1")

If this post helps click Yes
---------------
Jacob Skaria


"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

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      27th Jun 2009

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

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      27th Jun 2009

Can you clarify your question a little bit please? Are you looking to move
the last piece of data (the data in the last cell) on each row? If so, where
did you want to move them... to a single column? Could there be any blank
rows in the data? Approximately how many rows (maximum) do you expect to be
doing this for (your answer will determine how complicated an approach to
take)?

--
Rick (MVP - Excel)


"AlanW" <(E-Mail Removed)> wrote in message
news:5DC264DE-5664-4B3A-9005-(E-Mail Removed)...
>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


 
Reply With Quote
 
AlanW
Guest
Posts: n/a
 
      28th Jun 2009

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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... amorrison2006@googlemail.com Microsoft Excel Programming 2 7th Jun 2007 09:27 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Microsoft Excel Programming 4 12th Apr 2007 08:56 PM
Formula that will leave cell blank if cell is blank =?Utf-8?B?amltdG1jZGFuaWVscw==?= Microsoft Excel Programming 1 11th May 2006 07:26 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. =?Utf-8?B?UVVFU1Q0MTA2Nw==?= Microsoft Excel Misc 1 15th Jan 2005 09:29 PM
What is the difference between a blank cell and a (blank) cell in Pivot Table ? desktopbbb Microsoft Excel Misc 1 15th Aug 2003 09:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 AM.