+ Reply to Thread
Results 1 to 6 of 6

copy paste formulas using vba

  1. #1
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Question copy paste formulas using vba

    Hi again,

    I have a row where the first 4 cells contain data, and then next 7 cells contain formulas that manipulate that data.

    I have created a form that allows the user to input data into those first 4 cells. Within the subroutine that writes the data to the worksheet, I would like to tell it to copy the formulas in cells e:k of the previous row in the worksheet and apply those formulas and formats to the cells e:k where I have just written the data.

    I've been trying to do it with the use of a module with the following code

    Please Login or Register  to view this content.

    I then call the subroutine prior to writing in the data. What's happening is that it is copying the actual data from the previous row, and not the formulas or formats.

    Soma

  2. #2
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: copy paste formulas using vba

    Try...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: copy paste formulas using vba

    Thanks Domenic,

    I tried your code, but it didn't work for me.

    Soma

  4. #4
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: copy paste formulas using vba

    Hi,

    I made some changes to my original module it now reads


    Please Login or Register  to view this content.

    Basically, I changed .Value to .Formula. Problem now is

    1. I'm getting the exact same formula...for example... cell f2=a2+b2, and cell f3 should be =a3+b3, but i'm getting f3=a2+b2.

    2. It's not copying the format. Since I'm working with dates and times, I need the formats to be correct.

    Soma

  5. #5
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: copy paste formulas using vba

    Quote Originally Posted by soma104 View Post
    Thanks Domenic,

    I tried your code, but it didn't work for me.

    Soma
    What happened when you tried the code?

  6. #6
    Registered User
    Join Date
    11-28-2006
    Posts
    63

    Re: copy paste formulas using vba

    Quote Originally Posted by Domenic View Post
    What happened when you tried the code?
    Domenic, I must be losing it....

    When I tried your code none of the cells were being populated other than the first 4 that the user was inputting.

    I've made numerous adjustments to my code, and then tried yours again, and it worked perfectly.

    It was my mistakes that were causing the problems.

    Thanks so much.

    Soma

+ Reply to Thread

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