VBA to Copy and Paste Rows if Conditions are Met

lpw0806

New Member
Joined
Jun 14, 2018
Messages
38
Hi -

I am a first time poster on this site. I am still pretty green to VBA, but am learning and have made some small / short macros. I am familiar with SQL if that helps at all.

Right now I have a file with a "Raw Data" tab. I'd like to have a macro that states something like "IF Column A = "75" and Column B = "West" and Column C = "Local" etc etc then:

1) Create a new sheet titled 75
2) Paste that data into this new sheet.
--- note: Ideally I'd like to copy a handful of columns on the Raw Data tab instead of all of them.

I think there will need to be a "loop" involved here? Also - the number of rows is not sedentary and will always change.

Thanks in advance for the help on this!!! Much appreciated!
 
So close!!

What is happening is that the Sheet 1 tab (Raw Data) is being formatted incorrectly and thus the output is being formatted incorrectly now. Is there away to apply the formatting to only sheets 50,75,85,95 and 100? And exclude the Raw Data tab?

Thank you!!!
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Actually -- please disregard my last post. I was pasting in the Raw Data incorrectly.

This works PERFECTLY

THANK YOU SO SO SO SO SOOOOO MUCH
 
Upvote 0
Hi Again -

So I have a follow up question. I explained it in more detail in another post (https://www.mrexcel.com/forum/excel...data-into-tab-based-criteria.html#post5091078) - but thought I'd try and follow up here since it is similar to this macro you helped me with.

I got pretty far - but am having a hard time with

1) Matching the correct CM PROD (Column Q) to the correct category
2 ) Trying to combine this into one macro - Do I need 4 separate ones for each category?

Thank you!!!!

Sub Opportunities()
'
' Opportunities Macro


' Clear Data from Sheet
Sheets("Opportunities").Cells.Clear


' Filter Seller POD
Dim ary As Variant
Dim i As Long
ary = Array("Auto", "Multi", "Tech", "Lifestyle")

For i = 0 To UBound(ary)
With Sheets("Raw Data")
If .AutoFilterMode Then .AutoFilterMode = False
With .Range("A1:W1")
.AutoFilter 11, ">=" & 75
.AutoFilter 19, ary(i)
End With




Intersect(.AutoFilter.Range, .Range("A:A,C:C,S:S")).Copy Sheets("Opportunities").Range("A1")
.AutoFilterMode = False
End With
Next i


End Sub
 
Upvote 0
Please do not post the same question multiple times.
 
Upvote 0
I understand - this is different. It is allocating the $ in one column to a column on a new sheet based on criteria. Make sense?
 
Upvote 0
What I meant was, you already have a thread for the new question (which you supplied the link for), so you should not ask that here as well.
 
Upvote 0
Got it. Understood. Sorry about that. Just looking for answers on my second question and thought I'd ask since you were so helpful last time. Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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