View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Bob Kopp[_2_] Bob Kopp[_2_] is offline
external usenet poster
 
Posts: 3
Default Macro to move info and delete duplicat records

RBS

Thanks, that worked much better. I had titles in the first row when I ran
the macro and it did not like it. I just have to figure out how to delete
the row of data that I just moved for a particular item before it performs
the same action on the next row (item).

Data before Macro

0804706 BETCOCHEM AF79
0804706 JOHNSONSON 4605
0810295 CARLISLE 3663300
0810295 CARLISLE (O)4155900

Data after Macro

0804706 BETCOCHEM AF79 804706 BETCOCHEM AF79 JOHNSONSON 4605
0804706 JOHNSONSON 4605 810295 CARLISLE 3663300 CARLISLE (O)4155900
0810295 CARLISLE 3663300
0810295 CARLISLE (O)4155900

The Mfg info for item 0810295 got put on the same line as item 0804706.
After the data gets moved I need to delete row that the data was moved from.
I will have items with 4 or more MFG info that needs to be transcribed to one
item number.

You have been a great help so far and I appreciate your patience.

thanks,

bob




"RB Smissaert" wrote:

Did you have your example data in the range starting at A1?
It works fine with me.

Also would I have to rename arr to arr1 in order for it to get read by the
previous code that you sent me?


No, it doesn't matter how you call the array in the example Sub.
There is no relation between the array names in the function and the array
name in the calling Sub.

If you have the data in range A1 : C4 and run this Sub:

Sub Test()

Dim arr
Dim lStartPasteCol As Long

lStartPasteCol = 5

arr = Range(Cells(1), Cells(4, 3))
arr = SwingArray(arr, 1, False, 2, 0)
Range(Cells(lStartPasteCol), _
Cells(UBound(arr), _
(lStartPasteCol - 1) + UBound(arr, 2))) = arr

End Sub

It should just work fine.


RBS



"Bob Kopp" wrote in message
...
RBS

When I run the code that you just sent me to create the array, It gets
hung
up on line:

Range(Cells(5), Cells(UBound(arr), 4 + UBound(arr, 2))) = arr

Also would I have to rename arr to arr1 in order for it to get read by the
previous code that you sent me? If not, how does the array that this code
creates get brought into that code?

thanks,

bob

"RB Smissaert" wrote:

You don't have to understand it and the example I gave should work.
Only if you have to make adjustments will it need some understanding
what is going on. In that case just post back to this NG.

RBS

"Bob Kopp" wrote in message
...
RB Smissaert

I am playing with the code you provided me, but I am still very much a
noivce when it comes to the VBA programing language.

bob

"Bob Kopp" wrote:

I am in the process of trying to learn VBA. I am trying to write a
macro
that will go through a list of data in excel and:

1. Sort Data
2. Find duplicates
3.If duplicates are found, move certain information to open column of
the
master row
4. Delete Duplicate row

Problem

Item Mfg ID Mfg Itm ID Mfg ID-1 Mfg Itm ID-1 DFLT-1 Mfg ID-2
0804706 BETCOCHEM AF79
0804706 JOHNSONSON 4605
0810295 CARLISLE 3663300
0810295 CARLISLE (O)4155900

Hopefull End result

Item Mfg ID Mfg Itm ID Mfg ID-1 Mfg Itm ID-1
0804706 BETCOCHEM AF79 JOHNSONSON 4605
0810295 CARLISLE 3663300 CARLISLE (O)4155900

There will be multiple items that need to be moved to multiple
columns.
Bottom line is that I am trying to create unique item numbers that
could
have
multiple part numbers.

Any help would be much appreciated.

thanks,

bob