Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default variables in formulae

I am trying to create a variable from a formula.

The formula is a max() and a min() where the row numbers change and ar
variables. e.g I go to end of column and and set a variable calle
LastRow. Then I have another varaible that is MyRow which equal
LastRow-a number which has been inpuuted by an Input box.

Is there a way you can use a variable in a formula

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default variables in formulae

Dim a as variant
Dim rng as Range
Dim mMax as Double
Dim mMin as Double
Do
a = inputbox("enter number of rows - must be a number")
if a = "" then exit sub
Loop Until isnumeric(a)
set rng = Range(cells(lastrow- a +1 ,1),Cells(lastrow))
mMax = application.Max(rng)
mMin = Application.Min(rng)


--
Regards,
Tom Ogilvy



"Kelston " wrote in message
...
I am trying to create a variable from a formula.

The formula is a max() and a min() where the row numbers change and are
variables. e.g I go to end of column and and set a variable called
LastRow. Then I have another varaible that is MyRow which equals
LastRow-a number which has been inpuuted by an Input box.

Is there a way you can use a variable in a formula?


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default variables in formulae

Kelston,

Try something like

Dim LastRow As Long
LastRow = CLng(Application.InputBox(prompt:="Enter last row", _
Type:=1))
Debug.Print Application.Max(Range("A1:A" & LastRow))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Kelston " wrote in
message ...
I am trying to create a variable from a formula.

The formula is a max() and a min() where the row numbers change

and are
variables. e.g I go to end of column and and set a variable

called
LastRow. Then I have another varaible that is MyRow which

equals
LastRow-a number which has been inpuuted by an Input box.

Is there a way you can use a variable in a formula?


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Not at all clear on use of variables and/or object variables JMay-Rke Excel Discussion (Misc queries) 11 July 4th 08 06:36 PM
Formulae: Paste value formulae after doing an average operation Lim Excel Discussion (Misc queries) 4 April 20th 08 07:31 PM
Help with a formulae MDJ@TW Excel Worksheet Functions 0 October 20th 05 02:30 PM
3D formulae Steve Excel Discussion (Misc queries) 2 September 15th 05 08:28 AM
Searching TEXT in formulae, rather than results of formulae AndyE Excel Worksheet Functions 1 July 15th 05 10:57 AM


All times are GMT +1. The time now is 09:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"