+ Reply to Thread
Results 1 to 3 of 3

Need help placing variables in formula

  1. #1
    Registered User
    Join Date
    05-25-2010
    Location
    colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Need help placing variables in formula

    I have the following code in a module that is activated by a control button on UserForm1. I have ComboBox1 in Userform1 that allows selection of a list of years. I am trying to figure out a way to place that year that is selected into in the parameters of the formula that are in bold.

    Sub sumthem()
    Dim ws As Worksheet
    If UserForm1.ComboBox1.Value = "1st Quarter" Then

    With ThisWorkbook.Worksheets
    .Item(1).Range("J2").Formula = "=SUMIFS(E1:E2000,B1:B2000,"">=04-01-2014"",B1:B2000,""<=04-30-2014"")"
    .Item(1).Range("J2").NumberFormat = "$#,##0.00" 'currency format
    .FillAcrossSheets .Item(1).Range("J2"), xlFillWithAll


    .Item(2).Range("J3").Formula = "=SUMIFS(E1:E2000,B1:B2000,"">=05-01-2014"",B1:B2000,""<=05-31-2014"")"
    .Item(2).Range("J3").NumberFormat = "$#,##0.00" 'currency format
    .FillAcrossSheets .Item(2).Range("J3"), xlFillWithAll

    .Item(3).Range("J4").Formula = "=SUMIFS(E1:E2000,B1:B2000,"">=06-01-2014"",B1:B2000,""<=06-30-2014"")"
    .Item(3).Range("J4").NumberFormat = "$#,##0.00" 'currency format
    .FillAcrossSheets .Item(3).Range("J4"), xlFillWithAll

    .Item(4).Range("I2") = "Month 1"
    .FillAcrossSheets .Item(4).Range("I2"), xlFillWithAll
    .Item(5).Range("I3") = "Month 2"
    .FillAcrossSheets .Item(5).Range("I3"), xlFillWithAll
    .Item(6).Range("I4") = "Month 3"
    .FillAcrossSheets .Item(6).Range("I4"), xlFillWithAll

    .Item(7).Range("I1") = "Month"
    .FillAcrossSheets .Item(7).Range("I1"), xlFillWithAll
    .Item(8).Range("J1") = "OT Total"
    .FillAcrossSheets .Item(8).Range("J1"), xlFillWithAll

    End With
    Else: MsgBox "Not There"
    End If

    End Sub


    Any assistance is greatly appreciated!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help placing variables in formula

    This line seems to work

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-25-2010
    Location
    colorado, USA
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Need help placing variables in formula

    Thank You! I think that is the help that I needed.

+ 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. [SOLVED] Placing a Variable in A Formula
    By sdeaks in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 06-06-2014, 04:14 PM
  2. [SOLVED] Extracting two variables from one cell and placing them into columns of their own
    By Glayva in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-17-2013, 07:40 AM
  3. Placing Formula In Comment Boxes
    By dabomber7 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-05-2013, 06:39 PM
  4. Sorting/Placing Data by Three Variables
    By keenercoug in forum Excel General
    Replies: 1
    Last Post: 08-20-2010, 12:49 AM
  5. Placing a formula in a cell from VB
    By Paul Edwards in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-14-2008, 12:43 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