+ Reply to Thread
Results 1 to 3 of 3

Multi conditional transfer, relocate to existing and new rows VBA macro

  1. #1
    Registered User
    Join Date
    07-07-2020
    Location
    UK
    MS-Off Ver
    Office 365 - Exel 2016
    Posts
    11

    Multi conditional transfer, relocate to existing and new rows VBA macro

    Hi

    I'm looking for help with creating VBA code for a command button to transfer data from sheet 2 to sheet 1 when certain criteria has been met, but it also needs to update sheet 1 under certain circumstances and move existing data on sheet 1 to a new row and then copy the corresponding data from sheet 2 to the new row in sheet 1 whilst saving copies to worksheets within a new workbook at the appropriate time. I'll try to explain in greater detail below.



    On sheet 2
    Command button for transfer
    1. If any cell in column K on sheet2 has “Please choose Y/N” then Msgbox (“Please update all entries in column K”)
    2. The number to transfer (value of U11) must be equal to or greater than the number of available gift cards = in U15, Else Msgbox (“Not enough available”)
    3. If U9 > U15 then Msgbox (“Not enough available”)

    4. For all rows where column K (sheet 2) = Y
    Then find all the rows in sheet 1 where the value in U13 (Sheet 2) equals the value in Column N (sheet 1) AND, Column J (Sheet1) equals “Available” and Column H (sheet 1) equals U14 (sheet 2)
    Then for all the rows where column K (Sheet 2) = Y
    Copy cells in Column A (Sheet 2) to Column K (Sheet 1)
    Copy cells in Column B (Sheet 2) to Column L (Sheet 1)
    Copy cells in Column N (Sheet 2) to Column J (Sheet 1)
    Copy cells in Column O (Sheet 2) to Column N (Sheet 1)
    Copy cells in Column P (Sheet 2) to Column O (Sheet 1)
    Copy cells in Column Q (Sheet 2) to Column T (Sheet 1)
    Copy cells in Column R (Sheet 2) to Column U (Sheet 1)
    Copy cells in Column S (Sheet 2) to Column V (Sheet 1)

    Then save an export of the new rows – Column K to X to a new workbook
    Sheetname: Transferred
    Filename: Transferred + todays Date
    Folder Location: C:\ExampleLocation

    For all rows where column K (sheet 2) = N
    Then save an export of columns A to M on sheet 2 to a folder location under name of Not transferred + todays Date

    For all rows where column K (sheet 2) = Reassign
    Then find all the rows in sheet 1 where the value in column A (Sheet 2) equals the value in Column K (sheet 1) and Column J (Sheet1) equals “Assigned”
    For all the matching Rows In Sheet 1
    Change column J to “Closed”
    Column S to “Reassigned Closure”
    Column T to “Assignment Changed”
    Copy cells in Column R (Sheet 2) to Column U (Sheet 1)
    Copy cells in Column S (Sheet 2) to Column V (Sheet 1)

    Then cut the cells of that row in sheets 1 from A to H to a new line below the last row of Column I sheet1 and from the matching row in Sheet 2
    Copy cells in Column A (Sheet 2) to Column K (Sheet 1)
    Copy cells in Column B (Sheet 2) to Column L (Sheet 1)
    Copy cells in Column N (Sheet 2) to Column J (Sheet 1)
    Copy cells in Column O (Sheet 2) to Column N (Sheet 1)
    Copy cells in Column P (Sheet 2) to Column O (Sheet 1)
    Copy cells in Column Q (Sheet 2) to Column T (Sheet 1)
    Copy cells in Column R (Sheet 2) to Column U (Sheet 1)
    Copy cells in Column S (Sheet 2) to Column V (Sheet 1)

    Then save an export of the new rows – Column K to X to the same workbook under a new sheet
    Sheetname: Reassign added
    Filename: Transferred + todays Date
    Folder Location: C:\ExampleLocation

    Then save an export of the old rows – Column K to X to the same workbook under a new sheet
    Sheetname: Reassign removed
    Filename: Transferred + todays Date
    Folder Location: C:\ExampleLocation


    Is there a piece of vba code I could use to this within the command button? I'm new to learning VBA so only know little bits of it so far. Any help would be really appreciated.

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-29-2020
    Location
    NH USA
    MS-Off Ver
    365
    Posts
    2,103

    Re: Multi conditional transfer, relocate to existing and new rows VBA macro

    I have some questions. Sheet2 on the attachment has no data, is that how that process starts? And the transfer button is for the code you already started? I am trying to follow along so that I can help. Thanks

  3. #3
    Registered User
    Join Date
    07-07-2020
    Location
    UK
    MS-Off Ver
    Office 365 - Exel 2016
    Posts
    11

    Re: Multi conditional transfer, relocate to existing and new rows VBA macro

    Hi

    Thanks for looking into this. Yes sheet 2 will start blank and then column A and B will be used to locate duplicates in sheet 1. I've added some dummy data to demonstrate it a bit better and attached the file below. Doesn't have to use the existing code unless you think that's the best way?
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Conditional Transfer of Rows to Another Sheet
    By turkeyman2000 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-15-2014, 06:11 AM
  2. Macro to relocate specific info
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2011, 10:37 AM
  3. Replies: 2
    Last Post: 04-21-2011, 07:13 PM
  4. Relocate true rows to new tab
    By DoraExplorExcel in forum Excel General
    Replies: 1
    Last Post: 03-27-2007, 06:31 AM
  5. how do I transfer information from excel to an existing word document using a macro
    By sweetiez1114 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2005, 09:06 AM
  6. Function/macro to relocate RxC to CxR?
    By J.Kearney in forum Excel General
    Replies: 6
    Last Post: 03-28-2005, 06:06 AM
  7. Function/macro to relocate RxC to CxR?
    By J.Kearney in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-28-2005, 06:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1