#1   Report Post  
Posted to microsoft.public.excel.misc
flow23
 
Posts: n/a
Default copy

5 columns


Contact Reference Name Date of Transaction Amount Fundcode


If there is any data in column 5
then merge column 2 and 3 (in column 2)

and copy 4,5 and 6 column in column 3,4 and 5

then go to next row ....

pls help with this macro
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default copy

You sure you don't want to check column 6???

Try this against a copy!

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim myCell As Range
Dim myRng As Range

Set wks = ActiveSheet

With wks
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))

For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Offset(0, 4)) Then
'do nothing
Else
.Offset(0, 1).Value _
= .Offset(0, 1).Value & " " & .Offset(0, 2).Value
.Offset(0, 2).Value = ""
.Offset(0, 2).Delete shift:=xlToLeft
End If
End With
Next myCell
End With

End Sub

If IsEmpty(.Offset(0, 4)) Then
checks column 5. Change it to
If IsEmpty(.Offset(0, 5)) Then
if you want to check column F.



flow23 wrote:

5 columns

Contact Reference Name Date of Transaction Amount Fundcode

If there is any data in column 5
then merge column 2 and 3 (in column 2)

and copy 4,5 and 6 column in column 3,4 and 5

then go to next row ....

pls help with this macro


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
flow23
 
Posts: n/a
Default copy

thanks very much it works fab.

Yes The column 6 didnt came to my mind in the first place.

but I copied the same macro and changed the offsets accordingly.



"Dave Peterson" wrote:

You sure you don't want to check column 6???

Try this against a copy!

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim myCell As Range
Dim myRng As Range

Set wks = ActiveSheet

With wks
Set myRng = .Range("a2", .Cells(.Rows.Count, "A").End(xlUp))

For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Offset(0, 4)) Then
'do nothing
Else
.Offset(0, 1).Value _
= .Offset(0, 1).Value & " " & .Offset(0, 2).Value
.Offset(0, 2).Value = ""
.Offset(0, 2).Delete shift:=xlToLeft
End If
End With
Next myCell
End With

End Sub

If IsEmpty(.Offset(0, 4)) Then
checks column 5. Change it to
If IsEmpty(.Offset(0, 5)) Then
if you want to check column F.



flow23 wrote:

5 columns

Contact Reference Name Date of Transaction Amount Fundcode

If there is any data in column 5
then merge column 2 and 3 (in column 2)

and copy 4,5 and 6 column in column 3,4 and 5

then go to next row ....

pls help with this macro


--

Dave Peterson

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
Copy tabs(sheets) from workbook without link to original source Rich Ulichny Excel Discussion (Misc queries) 3 August 25th 05 02:11 AM
Copy shortcut BJH Excel Worksheet Functions 0 August 10th 05 12:41 AM
How can I copy cell formats in functions? Twitty Kitty Excel Worksheet Functions 3 July 24th 05 12:26 AM
Copy sheet 1 data to sheet 2 cells. Tom Doggett Excel Worksheet Functions 1 July 19th 05 11:49 PM
Copy without Hidden Cols - How abrogard Excel Discussion (Misc queries) 1 July 15th 05 07:54 AM


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

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"