Kacper Skrzyniarz
New Member
Members
Forum Posts: 2
Member Since:
November 26, 2020
November 26, 2020
Offline
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
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Riny van Eekelen
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1939
SunnyKow: 1432
Anders Sehlstedt: 918
Purfleet: 415
Frans Visser: 349
Hans Hallebeek: 333
David_Ng: 306
lea cohen: 248
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
Crystal Harris
Amaan Abdi
Sarah Yelland
Ahsan AYUB
Daniel Neilson
Joy Nicholes
Earl Hanlon
Paulo Pinto
Tavonga Machigere
Marc Poulopoulos
Forum Stats:
Groups: 3
Forums: 25
Topics: 7058
Posts: 30934
Member Stats:
Guest Posters: 49
Members: 34430
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —