+ Reply to Thread
Results 1 to 7 of 7

Macro to apply a new number and then copy the result to a new table

Hybrid View

  1. #1
    Registered User
    Join Date
    03-31-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    25

    Macro to apply a new number and then copy the result to a new table

    Hi,

    I have uploaded a spreadsheet to explain what I would like.

    Essentially, I want the numbers under days (B3 onwards) until the last number which may continue past B24 to go into H3 and be divided by 365, and then whatever appears in H4 to appear in the corresponding Rate column.

    Note, the rate won't change in this spreadsheet as it is just a dummy version.

    Any idea how this macro can be written

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro to apply a new number and then copy the result to a new table

    The first part is easy, second part not quite sure about - how do you determine where the value from H4 goes?

    Anyway here's the first part.
    For Each dy In Range("B3", Range("B" & Rows.Count).End(xlUp)))
        Range("H3").Value = dy.Value/365
    
        ' this is where you need to do the second part
    
    Next dy
    If posting code please use code tags, see here.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to apply a new number and then copy the result to a new table

    Maybe:

    Sub rongil20()
    Dim i As Long
    For i = 3 To Range("B" & Rows.Count).End(3).Row
        Cells(3, "H") = Cells(i, "B") / 365
        Cells(i, "C") = Cells(4, "H")
    Next i
    End Sub
    Last edited by JOHN H. DAVIS; 04-07-2015 at 08:49 AM.

  4. #4
    Registered User
    Join Date
    03-31-2015
    Location
    London
    MS-Off Ver
    2010
    Posts
    25

    Re: Macro to apply a new number and then copy the result to a new table

    Thanks John, did the job nicely

    And Norie, yes I wanted thee rate in H4 to populate the corresponding cell in column C

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro to apply a new number and then copy the result to a new table

    Quote Originally Posted by rongil20 View Post
    Thanks John, did the job nicely

    And Norie, yes I wanted thee rate in H4 to populate the corresponding cell in column C
    Think I got confused when I saw the columns of data in J:L etc.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro to apply a new number and then copy the result to a new table

    Wait a minute, do you want the value to go into the corresponding row in the Rate column where Days where taken from?

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to apply a new number and then copy the result to a new table

    You're welcome. Glad to help out. Please comply to the Forum rules and mark this thread as SOLVED. Refer too link for guidance.

    http://www.excelforum.com/forum-rule...rum-rules.html

+ 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. VBA macro to apply formula for selected cells and enter result below selection
    By Petrachabrova in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-23-2014, 07:39 AM
  2. [SOLVED] Apply Macro First UnprotectSheet After Apply Macro ProtectAgain Solved by : Sixthsense
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2014, 05:32 AM
  3. Apply Macro to a number of sheets
    By sush23 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-01-2012, 07:32 PM
  4. Automatically Apply Macro's/Formula's and Pivot Table attributes
    By karobonas in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-14-2011, 05:50 AM
  5. the result of a formula (number) copy as a text
    By Isabel1217 in forum Excel General
    Replies: 2
    Last Post: 01-31-2005, 02:13 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