vba help - fill blank and remove duplicate

Mallesh23

Well-known Member
Joined
Feb 4, 2009
Messages
976
Office Version
  1. 2010
Platform
  1. Windows
Hi Team,

My Input files Data is not coming in a same Row.it is Coming in two Row.

I want to Remove duplicate transaction ID. After adjusting top Row of Column E and F.

Below is my input Data.from Range("A1:F13")

Expected Output is in Range("a18:f24")

Below is my Data and expected Output. Thanks for your help in advance !

Book8
ABCDEF
1Sr NOTransaction IDAmountUser IDRemittanceUser Name
21435325xxx421mfg17abc
32435325586xxx
41438751xxx63715rtxyz
52438751701xxx
61438765xxx2715or1JKL
72438765587xxx
81438777xxx4715or1PQR
9243877798xxx
10134908xxx311326-2-ChargeJKL
11234908687xxx
12134925xxx319265-2-3-RefundXYZ
13234925738xxx
14
15
16
17Expected output
18Sr NOTransaction IDAmountUser IDRemittanceUser Name
192435325586xxx421mfg17abc
202438751701xxx63715rtxyz
212438765587xxx2715or1JKL
22243877798xxx4715or1PQR
23234908687xxx311326-2-ChargeJKL
24234925738xxx319265-2-3-RefundXYZ
Sheet1


Thanks
mg
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
How about
VBA Code:
Sub Mallesh()
   Intersect(Range("C:C").SpecialCells(xlBlanks).EntireRow, Range("A:D")).Delete xlUp
   Range("E:F").SpecialCells(xlBlanks).Delete xlUp
End Sub
 
Upvote 0
Hi Fluff,

Wow!! its amazing, it worked ! Thanks

Thanks
mg
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Hi Fluff,

Your code worked on given example,

But When Run on Actual data , I noticed some extra blanks (UserName and Remittance missing) , data huge noticed lately.

Range("A10:D14") which are highlighted in Red Color, There are no blanks and all transaction ID are Unique.

But there are Blanks in username and Remittance Column.

Found some exception in My Data. how to handle this situation.

Reanalysed data

Input Data ("A1:F22")
Expected OutPUt ("A26:F39")

Below Table.

Book9
ABCDEF
1Sr NOTransaction IDAmountUser IDRemittanceUser Name
21435325xxx421mfg17abc
32435325586xxx
41438751xxx63715rtxyz
52438751701xxx
61438765xxx2715or1JKL
72438765587xxx
81438777xxx4715or1PQR
9243877798xxx
10140012480xxx
111413822480xxx
1214122135000xxx
13141904322xxx
14141268555xxx
15134908xxx311326-2-ChargeJKL
16234908687xxx
17134925xxx319265-2-3-RefundXYZ
18234925738xxx
1917896askfjsPQR
202789620
21185123shfakabc
2228512319xxx
23
24
25Expected output
26Sr NOTransaction IDAmountUser IDRemittanceUser Name
272435325586xxx421mfg17abc
282438751701xxx63715rtxyz
292438765587xxx2715or1JKL
30243877798xxx4715or1PQR
31140012480xxx
321413822480xxx
3314122135000xxx
34141904322xxx
35141268555xxx
36234908687xxx311326-2-ChargeJKL
37234925738xxx319265-2-3-RefundXYZ
382789620askfjsPQR
3928512319xxxshfakabc
Sheet1



Thanks
mg
 
Upvote 0
Is this an accurate representation of your data?
 
Upvote 0
Hi Fluff,

Yes this is actual representation of data now. checked all input files of one week.


Thanks
mg
 
Upvote 0
Ok, how about
VBA Code:
Sub Mallesh()
   With Intersect(Range("C:C").SpecialCells(xlBlanks).EntireRow, Range("A:D"))
      .Offset(1, 4).Delete xlUp
      .Delete xlUp
   End With
End Sub
 
Upvote 0
Hi Fluff,

its perfect, it worked, Below is the code which I used in my actual data,
But I want understand how this lovely piece code works, Can you add comment plz.

VBA Code:
Sub Mallesh()
   With Intersect(Range("T:U").SpecialCells(xlBlanks).EntireRow, Range("A:V"))
      .Offset(1, 22).Delete xlUp  
      .Delete xlUp
   End With
End Sub '


Thanks.
mg
 
Upvote 0
If you change the .Delete xlUp to .Select & step through the code, you can see what it's doing.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,841
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top