Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cells with Values Edit

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?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Cells with Values Edit

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)

wrote in message
oups.com...
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?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Cells with Values Edit

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)

wrote in message
oups.com...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookup values in textbox and edit row Qaspec Excel Programming 0 August 4th 06 04:21 PM
converting formulas into values using a macro in visual basic edit F.C[_2_] Excel Programming 1 August 28th 05 09:52 AM
Getting pre edit values aps Excel Programming 2 July 27th 05 03:17 PM
edit x-values in XY Scatter? JethroUK© Charts and Charting in Excel 5 January 28th 05 11:41 PM
Edit/Find/Options/Look In/Values Hi Ho Silver Excel Worksheet Functions 1 January 13th 05 03:20 AM


All times are GMT +1. The time now is 09:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"