Results 1 to 3 of 3

VBA Code to copy row but not formula?

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-22-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    329

    Smile VBA Code to copy row but not formula?

    Good day all,

    I have a userform "command button" that populates a record into the next available row in Sheet "Form" when populated I have assigned a column to generate a unique number for the new row, once complete the code then transfers all data in that row to a second sheet "SWMS", the problem is it also copies the formula across & subsequently changes my unique code, how can I transfer just the data & not the formula?

    Private Sub cmdProcess_Click()
      Dim LastRow As Long
    
      LastRow = Sheets("Form").Range("a65536").End(xlUp).Row
      Sheets("Form").Unprotect Password:="000"
      Sheets("SWMS").Unprotect Password:="000"
      With Sheets("Form")
        .Range("A" & LastRow + 1).Value = TextBox1.Text
        .Range("B" & LastRow + 1).Value = TextBox2.Text
        .Range("C" & LastRow + 1).Value = TextBox3.Text
        .Range("D" & LastRow + 1).Value = TextBox4.Text
        .Range("E" & LastRow + 1).Value = TextBox5.Text
        .Range("F" & LastRow + 1).Value = TextBox6.Text
        .Range("G" & LastRow + 1).Value = TextBox7.Text
        .Range("H" & LastRow + 1).Value = TextBox8.Text
        .Range("I" & LastRow + 1).Value = TextBox9.Text
        .Range("J" & LastRow + 1).Value = TextBox10.Text
        .Range("K" & LastRow + 1).Value = TextBox11.Text
        .Range("L" & LastRow + 1).Value = ComboBox1.Text
        .Range("N" & LastRow + 1).Value = TextBox12.Text
        .Range("O" & LastRow + 1).Value = TextBox13.Text
      End With
      
    LastRow = Sheets("Form").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("Form").Range("A" & LastRow & ":O" & LastRow).Copy Worksheets("SWMS").Range("A1")
    Sheets("Form").Protect Password:="000"
    Sheets("Form").Protect Password:="000"
    
        MsgBox "SWMS Processed"
    
    End Sub

    Thank you all once again for your assistance, this site has been an amazing wealth of information for me - Marco
    Last edited by matrixpom; 10-24-2012 at 07:50 PM.

Thread Information

Users Browsing this Thread

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

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