Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Need help with macro to move cell data

I need to move cell data down 2 cells and over 1 cell to the left, then find
the next cell with data within the same column and repeat the move. Example:
B15 has a name in it and I need to move it to A17, then look 5 cells down in
column B for the next name and move it down 2 and over 1 cell. The number of
records varies greatly, so the macro needs to loop thru the records until
there are no more records.

The data is imported into Excel from a proprietary business application.

Thanks for any help!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with macro to move cell data

Sub Adjust Data()
set rng = Columns(2).SpecialCells(xlConstants)
for each cell in rng
cell.offset(2,-1).Value = cell
cell.ClearContents
Next
End sub

--
Regards,
Tom Ogilvy

"laralea" wrote in message
...
I need to move cell data down 2 cells and over 1 cell to the left, then

find
the next cell with data within the same column and repeat the move.

Example:
B15 has a name in it and I need to move it to A17, then look 5 cells down

in
column B for the next name and move it down 2 and over 1 cell. The number

of
records varies greatly, so the macro needs to loop thru the records until
there are no more records.

The data is imported into Excel from a proprietary business application.

Thanks for any help!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Need help with macro to move cell data

This helps, but it also moves data from 2 cells below the name to the right
column.

"Tom Ogilvy" wrote:

Sub Adjust Data()
set rng = Columns(2).SpecialCells(xlConstants)
for each cell in rng
cell.offset(2,-1).Value = cell
cell.ClearContents
Next
End sub

--
Regards,
Tom Ogilvy

"laralea" wrote in message
...
I need to move cell data down 2 cells and over 1 cell to the left, then

find
the next cell with data within the same column and repeat the move.

Example:
B15 has a name in it and I need to move it to A17, then look 5 cells down

in
column B for the next name and move it down 2 and over 1 cell. The number

of
records varies greatly, so the macro needs to loop thru the records until
there are no more records.

The data is imported into Excel from a proprietary business application.

Thanks for any help!!




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with macro to move cell data

Here is a modification to only work on cells that are not empty in
columns(2) [my omission, sorry]

Sub AdjustData()
Set rng = Columns(2).SpecialCells(xlConstants)
For Each cell In rng
If Not IsEmpty(cell) Then
cell.Offset(2, -1).Value = cell
cell.ClearContents
' Debug.Print cell.Address, cell.Offset(2, -1).Address
End If
Next
End Sub

Then testing it out

$B$15 $A$17
$B$20 $A$22


seemed to work as you described you wanted.

--
regards,
Tom Ogilvy

"laralea" wrote in message
...
This helps, but it also moves data from 2 cells below the name to the

right
column.

"Tom Ogilvy" wrote:

Sub Adjust Data()
set rng = Columns(2).SpecialCells(xlConstants)
for each cell in rng
cell.offset(2,-1).Value = cell
cell.ClearContents
Next
End sub

--
Regards,
Tom Ogilvy

"laralea" wrote in message
...
I need to move cell data down 2 cells and over 1 cell to the left,

then
find
the next cell with data within the same column and repeat the move.

Example:
B15 has a name in it and I need to move it to A17, then look 5 cells

down
in
column B for the next name and move it down 2 and over 1 cell. The

number
of
records varies greatly, so the macro needs to loop thru the records

until
there are no more records.

The data is imported into Excel from a proprietary business

application.

Thanks for any help!!






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
Macro to move data from one sheet to another Jurassien Excel Discussion (Misc queries) 0 January 22nd 07 10:22 PM
Move data Macro kingcole Excel Discussion (Misc queries) 2 July 10th 06 02:47 PM
Macro to move data to different column based on data in another co malycom Excel Discussion (Misc queries) 3 August 2nd 05 07:07 PM
enter data in cell which will start macro to move data to sheet2 Tommy Excel Discussion (Misc queries) 0 May 12th 05 05:00 PM
create macro to move label type data to column data JonathonWood9 Excel Programming 4 February 21st 05 10:53 PM


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