PC Review


Reply
Thread Tools Rate Thread

Cells with Values Edit

 
 
sfielder78@gmail.com
Guest
Posts: n/a
 
      10th Jan 2007
I wish to place the following values into a single row:
148 407
118 10003 169 364
15 222

i.e.
148 407 118 10003 169 364 15 222

I need to repeat this task over and over. The configuration of the
cells and values can be varied by the number of rows and cells they
occupy, no standard pattern will exist.
i.e the data could quite easily look like this:

186 452 12
12 212 50
50 268 47
47 10018 74 10084 58
58 285 141
141 399 143

I therefore need a sub in vba to count the number of rows and columns
with data before using this to organise it into a single row. My first
thought would be a select region then use the COUNTA function?

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      10th Jan 2007
Public Sub ProcessData()
Dim iLastRow As Long
Dim iLastCol As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 2 Step -1
iLastCol = Cells(i, "A").End(xlToRight).Column
Cells(i, "A").Resize(, iLastCol).Copy _
Cells(i - 1, "A").End(xlToRight).Offset(0, 1)
Next i
Rows(2).Resize(iLastRow - 1).Delete

End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I wish to place the following values into a single row:
> 148 407
> 118 10003 169 364
> 15 222
>
> i.e.
> 148 407 118 10003 169 364 15 222
>
> I need to repeat this task over and over. The configuration of the
> cells and values can be varied by the number of rows and cells they
> occupy, no standard pattern will exist.
> i.e the data could quite easily look like this:
>
> 186 452 12
> 12 212 50
> 50 268 47
> 47 10018 74 10084 58
> 58 285 141
> 141 399 143
>
> I therefore need a sub in vba to count the number of rows and columns
> with data before using this to organise it into a single row. My first
> thought would be a select region then use the COUNTA function?
>



 
Reply With Quote
 
sfielder78@gmail.com
Guest
Posts: n/a
 
      11th Jan 2007
Thanks - That did the job

Simon

Bob Phillips wrote:
> Public Sub ProcessData()
> Dim iLastRow As Long
> Dim iLastCol As Long
> Dim i As Long
>
> iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
> For i = iLastRow To 2 Step -1
> iLastCol = Cells(i, "A").End(xlToRight).Column
> Cells(i, "A").Resize(, iLastCol).Copy _
> Cells(i - 1, "A").End(xlToRight).Offset(0, 1)
> Next i
> Rows(2).Resize(iLastRow - 1).Delete
>
> End Sub
>
>
>
> --
> HTH
>
> Bob Phillips
>
> (replace somewhere in email address with gmail if mailing direct)
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I wish to place the following values into a single row:
> > 148 407
> > 118 10003 169 364
> > 15 222
> >
> > i.e.
> > 148 407 118 10003 169 364 15 222
> >
> > I need to repeat this task over and over. The configuration of the
> > cells and values can be varied by the number of rows and cells they
> > occupy, no standard pattern will exist.
> > i.e the data could quite easily look like this:
> >
> > 186 452 12
> > 12 212 50
> > 50 268 47
> > 47 10018 74 10084 58
> > 58 285 141
> > 141 399 143
> >
> > I therefore need a sub in vba to count the number of rows and columns
> > with data before using this to organise it into a single row. My first
> > thought would be a select region then use the COUNTA function?
> >


 
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
calculate values in an unlimited range of cells in a column WITHOUTalso calculating values that had previously been filtered AGAINST? yadang Microsoft Excel Misc 2 1st Oct 2009 06:18 PM
Exclude #N/A values and Return Numeric values to consecutive cells in Single Row Sam via OfficeKB.com Microsoft Excel Worksheet Functions 5 9th Feb 2008 03:07 AM
find values in multiple cells and paste row values izzyt1972 Microsoft Excel Misc 5 26th Dec 2007 10:14 PM
average values in non-contiguous cells, ignoring 0 values =?Utf-8?B?Uldvcm1kYWhs?= Microsoft Excel Worksheet Functions 3 30th Oct 2006 01:06 AM
How do I make X-values of a chart dependent on values in cells? Kashgarinn Microsoft Excel Charting 4 5th May 2004 03:10 PM


Features
 

Advertising
 

Newsgroups
 


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