+ Reply to Thread
Results 1 to 6 of 6

Swapping cell formulas using VBA

  1. #1
    Registered User
    Join Date
    04-25-2017
    Location
    Porto - Portugal
    MS-Off Ver
    2016
    Posts
    5

    Swapping cell formulas using VBA

    Hi !

    I'm having some difficulties in improving some excel data sheets to minimize time and eliminate errors and i need to add a VBA code to solve this problem.

    Example:
    By clicking the button a text box appears, "Select one cell in Pos A row".
    By selecting ID 1 line Pos A row, the formulas in Pos A and Descr A will be swapped unchanged, to the correspondent Pos B and Descr B in ID 1 Line. All formulas in Pos B and Descr B will go to Pos A and Descr A unchanged also ! Just in ID 1 Line
    If the Row of Pos A is not selected correctly, an error message will appears.

    Shortly explained: the formulas in green cells are swapped by the red cells and vice-versa.

    I have seen around the forum some question about this subject, but my limited VBA knowlodges are not able to solve the "select cell" problem .

    Swap.JPG


    P.S. : I was not able to upload the file to this post !


    Sam
    Last edited by 6StringJazzer; 04-25-2017 at 08:50 AM.

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Swapping cell formulas using VBA

    Here is how to load a file - it will help in this case.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    04-25-2017
    Location
    Porto - Portugal
    MS-Off Ver
    2016
    Posts
    5

    Re: Swapping cell formulas using VBA

    Hi !

    Here's my excel file so you can really see what i pretend to do.
    I have made some changes, but the main goal is intact...
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Swapping cell formulas using VBA

    I still need some more explanation. From the description, Column D should contain a formula and column E a text description. Column D does not contain a formula. For example, I cannot see where you are getting 345 A from A + 234.


    However, based on your description, the following should work.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-25-2017
    Location
    Porto - Portugal
    MS-Off Ver
    2016
    Posts
    5

    Re: Swapping cell formulas using VBA

    Sorry if i was not clear. That sheet is just an example.
    The formulas are a bit complex and the formulas info are collected from several tabs. In the real scenario, all values are collected data and formulas from other tables.

    Per example, On line 3, column D and E, the data contained in those cells will switch places with G and H.
    I understand the VB code to check the D column but not the rest.... How the D and E data will go tho G and H column ?

    Thanks for your help.

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,520

    Re: Swapping cell formulas using VBA

    Would need to see your exact formula's to get the best help. So this thread doesn't turn into a 30 post thread.

    P.S. The values on the table are from another table ...so, by swapping cells, the integrety of the formulas must be intact ! I want to copy the entire cells formulas without changing them.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

+ 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. Replies: 4
    Last Post: 10-19-2016, 02:45 PM
  2. Code for swaping columns
    By structo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-02-2016, 01:22 PM
  3. Using Cell references in file paths for formulas to create dynamic formulas
    By MichaelStokesJr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-04-2013, 11:49 AM
  4. Swaping and renaming columns macro
    By hugodevos in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2013, 09:04 PM
  5. Multiple formulas in selected cell without damaging previous formulas.
    By excel5111987 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-05-2011, 06:15 AM
  6. Replies: 5
    Last Post: 05-05-2008, 02:22 PM
  7. KEYBOARD SHORTCUT FOR SWAPING OF SHEETS
    By resolver in forum Excel General
    Replies: 2
    Last Post: 05-06-2006, 06:25 AM

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