ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Question as to why this will not run? (https://www.excelbanter.com/excel-programming/326047-question-why-will-not-run.html)

Melody

Question as to why this will not run?
 

-- New to using VB to write macros€¦.trying to get largest number in a column
and display that number within a message box€¦.program will compile but Im
getting a run time error.
Had programming experience in the past but its been quite some time!!!


Sub nextnum()
'
' nextnum Macro
' allows user to see next available number to assign to project
'
' Keyboard Shortcut: Ctrl+n
'
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " & [ActiveCell.FormulaR1C1]
End Sub

mms

Bob Phillips[_6_]

Question as to why this will not run?
 
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " & Activecell.Value

--

HTH

RP
(remove nothere from the email address if mailing direct)


"melody" wrote in message
...

-- New to using VB to write macros..trying to get largest number in a

column
and display that number within a message box..program will compile but I'm
getting a run time error.
Had programming experience in the past but it's been quite some time!!!


Sub nextnum()
'
' nextnum Macro
' allows user to see next available number to assign to project
'
' Keyboard Shortcut: Ctrl+n
'
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " &

[ActiveCell.FormulaR1C1]
End Sub

mms




Duke Carey

Question as to why this will not run?
 
If you don't need the MAX formula on your sheet for other reasons, do it all
with a single line

MsgBox "Next available Non Residential number is " & _
worksheetfunction.Max(activesheet.range("c144:c249 "))

"melody" wrote:


-- New to using VB to write macros€¦.trying to get largest number in a column
and display that number within a message box€¦.program will compile but Im
getting a run time error.
Had programming experience in the past but its been quite some time!!!


Sub nextnum()
'
' nextnum Macro
' allows user to see next available number to assign to project
'
' Keyboard Shortcut: Ctrl+n
'
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " & [ActiveCell.FormulaR1C1]
End Sub

mms


Tom Ogilvy

Question as to why this will not run?
 
Do you actually want to put the formula in the cell?

Sub AB()
ans = Application.Max(Range("C250").Offset(-106).Resize(106, 1))
msgbox "Next available Non Residential number is " & ans
End Sub

if you do:

Sub nextnum()
'
' nextnum Macro
' allows user to see next available number to assign to project
'
' Keyboard Shortcut: Ctrl+n
'
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " & [C250]
End Sub

--
Regards,
Tom Ogilvy



"melody" wrote in message
...

-- New to using VB to write macros..trying to get largest number in a

column
and display that number within a message box..program will compile but I'm
getting a run time error.
Had programming experience in the past but it's been quite some time!!!


Sub nextnum()
'
' nextnum Macro
' allows user to see next available number to assign to project
'
' Keyboard Shortcut: Ctrl+n
'
Range("C250").Select
ActiveCell.FormulaR1C1 = "=MAX(R[-106]C:R[-1]C)"
MsgBox "Next available Non Residential number is " &

[ActiveCell.FormulaR1C1]
End Sub

mms





All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com