+ Reply to Thread
Results 1 to 3 of 3

Transferring data using a macro button but skipping out columns containing formulas

  1. #1
    Registered User
    Join Date
    11-29-2018
    Location
    London
    MS-Off Ver
    MS Office 365
    Posts
    2

    Transferring data using a macro button but skipping out columns containing formulas

    Hello,

    I have created a front-end user form designed to transfer data entered, across to a worksheet using a macro button. This works successfully, however a number of the columns in the destination worksheet include formulas. When the data is transferred, the formulas are wiped and the data is pasted as blank text.

    However, I require the functionality of being able to amend/update this data in the worksheet, which means that I still require the formulas to exist.

    Is there a way I can get the macro to skip columns out so that the columns containing formulas remain untouched?

    Below is the VBA code used in the Macro:


    Sub UpdateLeadWorksheet()

    'cells to copy from Input sheet - some contain formulas
    myCopy = "C7:C19,G7:G9,G11:G18,K7:K12,K14:K19"

    Set inputWks = Worksheets("Lead Input Form")
    Set historyWks = Worksheets("Lead")

    With historyWks
    nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    End With

    With inputWks
    Set myRng = .Range(myCopy)
    End With

    End Sub




    I have attempted fixing this by amending the copied cells to skip out the columns I wish to keep the formulas in, but this has not worked. My attempt to fix is below:



    Sub UpdateLeadWorksheet()

    'cells to copy from Input sheet - some contain formulas
    myCopy = "C7:C15,C18:C19,G7:G9,G11:G18,K7:K12,K14:K19"

    Set inputWks = Worksheets("Lead Input Form")
    Set historyWks = Worksheets("Lead")

    With historyWks
    nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    End With

    With inputWks
    Set myRng = .Range(myCopy)
    End With

    End Sub




    Any help / advice would be very much appreciated.

    Many thanks in advance.

    Adam
    Last edited by AdamMc93; 11-29-2018 at 07:58 AM.

  2. #2
    Forum Expert
    Join Date
    11-28-2015
    Location
    indo
    MS-Off Ver
    2016 64 bitt
    Posts
    1,513

    Re: Transferring data using a macro button but skipping out columns containing formulas

    Perhab
    Please Login or Register  to view this content.
    Last edited by daboho; 11-29-2018 at 08:22 AM.

  3. #3
    Registered User
    Join Date
    11-29-2018
    Location
    London
    MS-Off Ver
    MS Office 365
    Posts
    2

    Re: Transferring data using a macro button but skipping out columns containing formulas

    Hi daboho,

    Thank you for your reply. I have attempted including your suggested solution however it is returning a "400" error message

    I have now had to add to the VBA code however to incorporate additional functions, please find new code below:




    Sub UpdateLeadWorksheet()

    'cells to copy from Input sheet - some contain formulas
    myCopy = "C7:C19,G7:G9,G11:G18,K7:K12,K14:K19"

    Set inputWks = Worksheets("Lead Input Form")
    Set historyWks = Worksheets("Lead")

    With historyWks
    nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row
    End With

    With inputWks
    Set myRng = .Range(myCopy)
    End With

    With historyWks
    With .Cells(nextRow, "A")
    .Value = Now
    .NumberFormat = "mm/dd/yyyy hh:mm:ss"
    End With
    .Cells(nextRow, "B").Value = Application.UserName
    oCol = 3
    For Each myCell In myRng.Cells
    historyWks.Cells(nextRow, oCol).Value = myCell.Value
    oCol = oCol + 1
    Next myCell
    End With

    'clear input cells that contain constants
    With inputWks
    On Error Resume Next
    With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
    .ClearContents
    Application.GoTo .Cells(1) ', Scroll:=True
    End With
    On Error GoTo 0
    End With
    End Sub




    Anything in this additional code that may be hindering your suggestion?

    I look forward to your response.

    Thanks,
    Adam

+ 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] Help transferring a formula from one sheet to another but skipping cells
    By dondada82 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-24-2017, 02:13 AM
  2. [SOLVED] VBA To copy cells in a range that contain data skipping formulas
    By lday75 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 04-16-2016, 04:46 PM
  3. Macro Button to copy last row of data, transposed, skipping a row to another sheet
    By travreed7 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2015, 01:59 AM
  4. [SOLVED] ADD BUTTON for transferring Data.
    By isameer in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-04-2014, 01:24 AM
  5. Transferring a line of data from one tab to another using formulas
    By MSpring in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-30-2014, 11:54 AM
  6. Replies: 1
    Last Post: 06-14-2012, 01:58 PM
  7. Replies: 4
    Last Post: 06-23-2009, 09:57 PM

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