Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default moving cells to another column based on number of characters

I download a report each day that varies in length so my row count is
unknown. About 20 cells populate in column H that should be in column I.
Below is a sample. The correct information in Col H is normally 6
characters. The longer 13 character number belongs in Col I. As you can
see, the cell in column I is empty when the data is incorrectly in column H
on the same row. I'm not sure the best code to put in an existing macro for
the active sheet to move the cells in column H to column I when the text in
the cell is greater than 6. I'm grateful for any help you can give me.
H I

N430AF 0009119181112
N39D93 0000730756201
0000730756201
932257786
N38C72 979722772
N42C26 0001875221211
N3677D 0009650691112

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default moving cells to another column based on number of characters

Sub MoveValues()
Dim rng as Range, cell as Range
set rng = Range(cells(2,"H"),cells(rows.count,"H").end(xlup) )
for each cell in rng
if len(cell) = 13 then
cell.offset(0,1).value = cell.value
cell.clearcontents
end if
next
End sub

test it on a copy of your data.

--
Regards,
Tom Ogilvy



"JOUIOUI" wrote:

I download a report each day that varies in length so my row count is
unknown. About 20 cells populate in column H that should be in column I.
Below is a sample. The correct information in Col H is normally 6
characters. The longer 13 character number belongs in Col I. As you can
see, the cell in column I is empty when the data is incorrectly in column H
on the same row. I'm not sure the best code to put in an existing macro for
the active sheet to move the cells in column H to column I when the text in
the cell is greater than 6. I'm grateful for any help you can give me.
H I

N430AF 0009119181112
N39D93 0000730756201
0000730756201
932257786
N38C72 979722772
N42C26 0001875221211
N3677D 0009650691112

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
Count Number of Discrete Cells, Based on Another Column RJB Excel Discussion (Misc queries) 8 June 4th 08 05:22 AM
Count number of cells and total in one column, based on another column suffix Pierre Excel Worksheet Functions 5 October 31st 07 12:28 AM
Deleting rows based on number of characters catalfamo1220 Excel Discussion (Misc queries) 3 July 20th 06 06:31 PM
How assing unique number in a column based on a combination of two cells galin Excel Programming 1 February 1st 06 05:25 PM
Moving Cursor once set number of characters are entered. Parkeand Excel Programming 0 July 14th 04 05:52 AM


All times are GMT +1. The time now is 04:20 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"