Results 1 to 10 of 10

Find date in horizontal table and add values below in one cell

Threaded View

  1. #1
    Registered User
    Join Date
    08-19-2012
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    50

    Find date in horizontal table and add values below in one cell

    Greetings!
    What I want to accomplish is that the macro finds the current date in a horizontal table with multiple rows of dates, and then add one number below and below that 3 other numbers as %-numbers in that style: xx/yy/zz (30/40/30 for example). The point is it should not add the digits after the commata, but take the full number without %-symbol (37,53% =38). You can find my code here, its commented to make it easy to understand. By helping me you would make me very happy because I'm not getting it on my own or with google like my other macros.


    Sub Tagebucheintrag()
    Dim Kcal As Integer 'Kcal ist the first number 
    Dim Prot As Integer 'these 3 are the %-numbers to be added in the 2nd cell below the date xx/yy/zz
    Dim Carb As Integer
    Dim Fat As Integer
        Kcal = Worksheets("Diätplaner").Cells(36, 5).Value
        Prot = Worksheets("Diätplaner").Cells(37, 6).Value
        Carb = Worksheets("Diätplaner").Cells(37, 6).Value
        Fat = Worksheets("Diätplaner").Cells(37, 6).Value     'I set the variables with the numbers I want to be written below the date
        Worksheets("Diätlog").Activate 
        Range("B1:B1,AF:AF").Find(Date).select   'in the other worksheet I search in the range of b1 to the end of AF for the current date.
        Cells(ActiveCell.Row + 1, ActiveCell.Column).Value = Kcal 'the macro adds the first variable into the cell below
        Cells(ActiveCell.Row +2,activecell.column).value = Prot&"/"&Carb&"/"&Fat 'the macro combines the 3 variables to the format xx/yy/zz
    
    
    End Sub
    Ive tried it and it doesnt even find the current date and selects the cell :/

    Yours sincerely,
    Taktiker from Germany, who feels drunken from doing Excel macros without really having any knowledge about VBA
    Last edited by Taktiker; 08-19-2012 at 04: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