+ Reply to Thread
Results 1 to 4 of 4

How to add range in a Formula through VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    07-01-2014
    Location
    New Delhi , India
    MS-Off Ver
    2007
    Posts
    51

    How to add range in a Formula through VBA

    Dear All,

    I have attached a sales tracker ,every month i have to add a range to get the the min and max value.
    Now i want to automate the same min and max formula with the help of Vba .
    Can any one please help me .

    Dim InptboxName As String
    Rows("1:1").Select
    colno = Selection.Find("Min").Column
    Cells(1, colno).EntireColumn.Insert
    Cells(1, colno).Offset(2, 0).Select
    InptboxName = InputBox("Enter the Name of Month") 'December
    ActiveCell.Value = InptboxName
    ActiveCell.Offset(1, 1).Select
    ' Automate the formula of min and max.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to add range in a Formula through VBA

    Hi,

    VBA is not needed. You could use standard Excel functions.
    Here's one array formula - (enter with Ctrl-Shift-Enter) in AJ4 and copy down
    Put the letter Q in row 1 above every Quarter column so that the formula can ignore those columns

    Formula: copy to clipboard
    =MAX(IF(($C4:$AK4<>"n/a"),IF(C$1:AK$1<>"Q",$C4:$AK4,0),0))

    Change MAX to MIN for the minimum value.

    Personally I'd be inclined to capture your data in a normalised 2 dimensional table of column field headers and rows for every record that could be used by a pivot table, or by simpler formulae in any pre-formatted Sales Report.
    i.e. Have a separate sheet in which you have columns for recording:

    Date
    TP Name *
    Product Name *
    Quantity

    The * fields could be drop down validation cells that contain a list of the allowable choices like say "TV", "Furniture"..etc to make Data entry even simpler.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    07-01-2014
    Location
    New Delhi , India
    MS-Off Ver
    2007
    Posts
    51

    Re: How to add range in a Formula through VBA

    Thanks ,

    But i would like to do in VBA only , as only a part of data i have shared .
    There were several tasks i have to perform on the same sales tracker.
    So Please suggest me if it would be done through VBA.

    Thanks

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How to add range in a Formula through VBA

    Quote Originally Posted by jhabijay_10 View Post
    Thanks ,

    But i would like to do in VBA only , as only a part of data i have shared .
    There were several tasks i have to perform on the same sales tracker.
    So Please suggest me if it would be done through VBA.

    Thanks
    Why not apply the formula I gave you USING VBA if you don't want to add it manually?

+ 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] Make data range in formula shift for a whole range when copying cell
    By Zaron in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-21-2016, 06:37 AM
  2. Replies: 1
    Last Post: 11-24-2015, 03:00 AM
  3. Replies: 1
    Last Post: 03-02-2015, 11:18 AM
  4. Replies: 2
    Last Post: 09-01-2014, 07:59 AM
  5. [SOLVED] chart based on dynamic range which resizes as per data in range-formula / vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-11-2014, 04:02 PM
  6. Replies: 1
    Last Post: 09-04-2013, 07:23 AM
  7. Replies: 1
    Last Post: 06-17-2006, 09:10 PM

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