Exclude Specific Columns from Range in VBA

alpha_xero

New Member
Joined
Sep 14, 2022
Messages
6
Office Version
  1. 2021
  2. 2019
  3. 2016
Platform
  1. Windows
Hello,
I have a code that returns unique rows from one sheet to another.
I want to exclude specific columns from the range from B5:P1048576 and show them in Sheets("Item-Wise Summary").Range("A5:O5")

VBA Code:
Sub RemoveDuplicates()

Dim rngDatabase As Range

'define the database

   Set rngDatabase = Sheets("Transaction Entry").Range("B5:P1048576")

'filter the database to a new range with a unique set to true

rngDatabase.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("Item-Wise Summary").Range("A5:O5"), Unique:=True

End Sub
 

Attachments

  • Screenshot 2022-09-14 181124.jpg
    Screenshot 2022-09-14 181124.jpg
    125.7 KB · Views: 25
  • Screenshot 2022-09-14 181218.jpg
    Screenshot 2022-09-14 181218.jpg
    109.3 KB · Views: 26
Yes that's the thing! If I put 11 columns on the output I'm getting this error message.
I tried the code you gave me but its not working either. This has nothing to do with the actions.

Anyways this is giving me a lot of pain and I guess I'll have to try a different approach.

1663667077217.png
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Yes that's the thing! If I put 11 columns on the output I'm getting this error message.
I tried the code you gave me but its not working either. This has nothing to do with the actions.

Anyways this is giving me a lot of pain and I guess I'll have to try a different approach.
1) Like I said your code won't work because Advanced Filter won't work on non-contiguous range (skipping columns in your filter range)

2) Not working doesn't tell me anything.
The only thing the Actions code is doing is working out the Qty figures, it should not stop the code working at worst should give you the Qty column when you don't want it yet.
In terms of the Qty the code is trying to work out whether a transaction Qty should be treated as Stock In (positive) or Stock Out (negative). Just ignore that if you don't want it and tell me what "not working" means.
Do you get an error message, if so show me the message and which line is highlighted when you click on debug ?
If the results are wrong show me what you are getting and what you were expecting.
 
Upvote 0
Hey Alex,
If Advanced Filter won't work on non-contiguous range, that answers my question.
Thank you so much for your time and support. You've really helped so much.
Also, do you know how I can delete this whole thread? There seems to be no option for that.
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,686
Members
452,994
Latest member
Janick

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