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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

SteveO59L

Well-known Member
Joined
Apr 21, 2004
Messages
7,899
Why not auto filter on your sales region and just copy and paste into a new sheet ?
 

R_Stephens

Board Regular
Joined
Dec 23, 2004
Messages
143
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
 

Forum statistics

Threads
1,147,688
Messages
5,742,629
Members
423,745
Latest member
rtaylor1987

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
Top