automatically move data to another worksheet

welsh_decs

New Member
Joined
Nov 25, 2013
Messages
14
I am not sure which section this would come under.

I work for a company that has 8 or 9 holiday parks.

We have a spreasheet for the company credit card.

The first sheet has all the credit card transactions, one of the columns on this sheet is named "Park" where we input the name of the park that the transaction is for.

then there are 8 other sheets one for each of the parks.

Is there a formula or anything I can do that when we input the name of the park into the "Park" column that it automaticall transfers that row of information into the correct sheet for that park.

I did try to do one with a macro and it worked however, I had to click the update entry button (i created to run the macro) everytime I entered a line, and also if i had 2 entries for one park the second one would overwrite the first one (it wouldnt go to the next available row)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hi..
Is there a formula or anything I can do that when we input the name of the park into the "Park" column that it automaticall transfers that row of information into the correct sheet for that park.

Firstly.. best to have the 8 parks in a Data Validation List for each row.. quicker and no user input error..

You could hook onto the Sheet Change event for the cells the Park Validation lists are in and copy your row to the correct sheet when a selection is made..

You would also need to add validation that all the fields required were filled in so the row doesn't get transferred when it is only half filled in..

On the other hand. you could alternatively use a Userform to enter the data (saving it to the master sheet of all transactions and also to each park sheet at same time)..
If your Workbook (anonymise the data).. to a place like dropbox or mediafire both have free accounts).. I can probably give you a hand... :)
 
Upvote 0
Hi..

This should do it.. i added a validation lists for your "Parks" and a nice date picker for date entry in Column A (just click a cell in Column A)

See it implemented in the attached file..

Credit%20Card%20Spreasheet

Code:
Private Sub CommandButton1_Click()
    Dim lr As Long, n As Long
    Dim CpyRng As Range, CpyToRng As Range, rRngToClear As Range

    With Application
        .EnableEvents = False
        .DisplayAlerts = False
        .ScreenUpdating = False
    End With

    With Sheets("Overview").Range("A1:D35")
        For i = 2 To Worksheets.Count - 3
            lr = Sheets(Sheets(i).Name).Range("A" & Rows.Count).End(xlUp).Row + 1
            .AutoFilter 4, Sheets(i).Name
            n = Range("A1:D35").SpecialCells(12).SpecialCells(2).Count

            If n > 4 Then
                'Setup the Ranges to Copy From and To
                Set CpyRng = Sheets("Overview").Range("A1").CurrentRegion.Offset(1).SpecialCells(12)
                Set CpyToRng = Sheets(Sheets(i).Name).Range("A" & lr)
                CpyRng.Copy Destination:=CpyToRng

                'Build Range that will be cleared
                If rRngToClear Is Nothing Then
                    Set rRngToClear = CpyRng
                Else
                    Set rRngToClear = Union(rRngToClear, CpyRng)
                End If
            End If
        Next i
        ' Clear the rows that were transferred
        If Not rRngToClear Is Nothing Then
            rRngToClear.ClearContents
        End If

        .AutoFilter
    End With
    Cells(2, 2).Select
    With Application
        .EnableEvents = True
        .DisplayAlerts = True
        .ScreenUpdating = True
    End With
End Sub

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("A2:A35")) Is Nothing Then
        CalendarFrm.Show
    End If
End Sub
 
Upvote 0
Thank you thank you so much for all your help.

I have one slight query would it it be possible so that once all the rows have been transferred they stay on the overview tab and also move to the relevant park?

If i need to edit the parks at all (e.g. to add more parks) to the drop down list how would I go about that? and if i added more tabs for more parks would i need to re do the macro?
 
Last edited:
Upvote 0
Hi..

I have one slight query would it it be possible so that once all the rows have been transferred they stay on the overview tab and also move to the relevant park?

The problem with that is that rows that have already been transferred will be transferred again when the button is pressed again..
You could maybe get around this by making it so ALL rows get transferred to a MASTER sheet as well as to each individual parks sheet.. that way you will have a cpoy of ALL transactions (which you can manually sort/filter if looking for something).. and also each sheet will be populated.. basically.. it means you leave that first sheet (Overview) as more of a "Entry" sheet..

If i need to edit the parks at all (e.g. to add more parks) to the drop down list how would I go about that?

Add more Parks to the List on the "Data" sheet i added.. you could make that into a Dynamic Named Range and reference that Named Range in the Data Validation List.. or for now.. if you add a new park to the Data sheet.. click on your first Data Val cell and then goto the Data Tab > and change the Source range.

You can either drag this first cell with the Val List in it down again to row 35 or click "Apply to Cells with Same Settings" option..

and if i added more tabs for more parks would i need to re do the macro?

Currently,, I am making it skip the first sheet and the last 3 sheets using this code..
So you will just need to adjust that or place your sheets in between there..

Code:
For i = 2 To Worksheets.Count - 3

Hope that helps.. if you need any more help.. yell out.. :)
 
Upvote 0
right ok all problem sorted except for doing a master sheet that all transactions go to no matter of whats entered into the park column?

how do i go about this?
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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