Copying rows into another worksheet......

Steve Jones

New Member
Joined
Jan 18, 2005
Messages
12
Hi,

I have a spreadsheet for sales information with a sales region allocated to each record.

Is there a way that I could create a formula/Macro that will copy rows with the same region into a seperate worksheet?. The sales region column is "g" if this helps!?!?!

Any assistance would be really usual as it will save me hours of my time.

Thanks in advance.

Steve
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi there,

The following code will copy any lines with a selected Region in column G to Sheet 2. Its quiet simple, so make sure you empty Sheet2 before re-running it as it will overwrite any lines there previously. Make sure the code copies things as you need before we overcomplicate things.
From your sheet with Data on it, run the macro and type in the Region you want to copy to Sheet2.

Code:
Dim criteria As String
Dim x As Long
Dim y As Long
criteria = InputBox("Enter Region to Copy", "Select Region")
y = 1
For x = 1 To 65536
    If Cells(x, 7).Value = criteria Then
        Cells(x, 7).EntireRow.Copy
        Sheets("Sheet2").Cells(y, 1).PasteSpecial
        y = y + 1
    End If
Next x
Application.CutCopyMode = False

Hope this helps

Richard
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

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