ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   moving cells to another column based on number of characters (https://www.excelbanter.com/excel-programming/363649-moving-cells-another-column-based-number-characters.html)

JOUIOUI

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


Tom Ogilvy

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



All times are GMT +1. The time now is 12:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com