+ Reply to Thread
Results 1 to 9 of 9

Copy Formula from 1 column to the other

  1. #1
    Registered User
    Join Date
    09-21-2013
    Location
    Duabi
    MS-Off Ver
    2010
    Posts
    4

    Copy Formula from 1 column to the other

    Hi Guys,

    I have created a macro where I can drag and copy the forulma to the next column. The issue I am facing is this that I have created the command button on a seperate sheet and when I click it it runs the macro only if I place my cursor to the next column of the data sheet. My macro is as follows and I have attached the file to show where I would like to copy my formula (From Mar-13 to Apr-13) Please see the attached file.


    Sub UpdateBS()
    Sheets("YTD Balance Sheet").Select
    ' Keyboard Shortcut: Ctrl+b
    '
    ActiveCell.Offset(0, -1).Range("A1:A2").Select
    Selection.AutoFill Destination:=ActiveCell.Range("A1:B2"), Type:= _
    xlFillDefault
    ActiveCell.Range("A1:B2").Select
    ActiveCell.Offset(3, 0).Range("A1:A73").Select
    Selection.AutoFill Destination:=ActiveCell.Range("A1:B73"), Type:= _
    xlFillDefault
    ActiveCell.Range("A1:B73").Select
    ActiveCell.Offset(0, 1).Columns("A:A").EntireColumn.EntireColumn.AutoFit
    ActiveCell.Offset(44, 1).Range("A1").Select
    End Sub
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Copy Formula from 1 column to the other

    please use code tags while posting codes

    try this code..
    Please Login or Register  to view this content.
    Thanks - Naveed
    -----------------------------
    If the suggestion helps you, then Click * to Add Reputation
    To Attach File: Go Advanced>>Manage Attachments>>Add Files (In Top Right Corner)>>SelectFiles>>.........Locate Your File(s)>>Upload Files>>Done (In Bottom Right)
    1. Use [code] code tags [\code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    2. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

  3. #3
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Copy Formula from 1 column to the other

    please use code tags while posting codes

    try this code..
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-21-2013
    Location
    Duabi
    MS-Off Ver
    2010
    Posts
    4

    Re: Copy Formula from 1 column to the other

    Aslamualaikum,


    Thanks for helping me out with the formula. I tried the ocde but it has not worked what it does is this that after running the code it takes me to the YTD Balance sheet work sheet and to the cell A1 but it does not drag and coipy the formula. I have attached two more files to give you a better idea what I am trying to do.

    Thanks in advance appreciate your help[
    Attached Images Attached Images

  5. #5
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Copy Formula from 1 column to the other

    walekum assalam,

    if possible could you please provide excel sample workbook its make very easy to resolve..

  6. #6
    Registered User
    Join Date
    09-21-2013
    Location
    Duabi
    MS-Off Ver
    2010
    Posts
    4

    Re: Copy Formula from 1 column to the other

    Aslamualaikum,

    Please find the attachment. Please note that I would like to copy and drag formula from March to April to May and so on and when the macro is run it should only copy and paste date into the next month also I would like the command button to be created on 'Command Button Tab' and linked with macro. If you have any questions please ask

    Jazak Allah.
    Attached Files Attached Files
    Last edited by aounhanif; 09-22-2013 at 02:11 AM.

  7. #7
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Copy Formula from 1 column to the other

    now try this attached file and let me know if you have any question feel free to ask


    hope this will work
    Attached Files Attached Files

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Copy Formula from 1 column to the other

    Hi, Naveed,

    is there a special reason you get the value for LR but donīt use it furthermore but use EntireColumn instead?
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  9. #9
    Valued Forum Contributor Naveed Raza's Avatar
    Join Date
    11-04-2012
    Location
    India, Hyderabad
    MS-Off Ver
    Excel, Access 2007/2010
    Posts
    1,338

    Re: Copy Formula from 1 column to the other

    Sure sir,

    thank you so much for guiding me and helping me in making code in proper manner

    once again thanks...

+ 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: 3
    Last Post: 01-30-2013, 04:32 PM
  2. Replies: 7
    Last Post: 11-12-2012, 02:46 PM
  3. Copy Formula down the column based on data in the next column
    By karl_009 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2008, 09:48 AM
  4. Copy Formula:copy the exact same formula in one column
    By Leprechaun in forum Excel General
    Replies: 1
    Last Post: 12-11-2006, 07:46 PM
  5. Copy a formula to cells in column A which don't have an empty cell in column B
    By floep in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-24-2006, 04:57 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