Notifications
Clear all
General Excel Questions & Answers
4
Posts
2
Users
0
Reactions
9
Views
Topic starter
Hi all
I have following problem with VBA. I want to subtract coresponding value from selected range with column offset (screenshot in attachment).
I came to point where excel return min value from range, but I don't know how to point to subtract corespoding cell.
Sub a()'PURPOSE: Apply A Yellow Fill Color To A Cell RangeDim rng As RangeDim DefaultRange As RangeDim FormatRuleInput As String'Determine a default range based on user's SelectionIf TypeName(Selection) = "Range" ThenSet DefaultRange = SelectionElseSet DefaultRange = ActiveCellEnd If'Get A Cell Address From The User to Get Number Format FromOn Error Resume NextSet rng = Application.InputBox( _Title:="Cans choice", _prompt:="Select desired cans", _Default:=DefaultRange.Address, _Type:=8)Range("H3").Value = Application.WorksheetFunction.Min(rng.Offset(, 1))Range("I3").Value = Application.WorksheetFunction.Max(rng.Offset(, 2))With Worksheets("Sheet1")MinVal = WorksheetFunction.Min(rng.Offset(, 1))Range("F1").Value = MinValEnd WithOn Error GoTo 0'Test to ensure User Did not cancelIf rng Is Nothing Then Exit SubEnd Sub
Posted : 27/11/2020 3:27 am
Hello,
you can upload a demo file, without confidential data, it would be easier and faster to help
Miguel,
Posted : 27/11/2020 1:47 pm
Topic starter
Hi Miguel
I am doing it on demo file basically, please find it attached.
Regards
Kacper
Posted : 28/11/2020 3:00 am
Hello,
file not attached!
see how to attach a file: _ excel-forum _ forum-rules-and-guides _ read-this-first _ video (How To Create a Post and Attach a File) Miguel,
Posted : 28/11/2020 7:59 am