Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,081
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



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
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
where can I see my question and answer? Yesterday I ask a question IP Excel Discussion (Misc queries) 2 May 10th 08 04:08 PM
Add-In question Geoff Setting up and Configuration of Excel 1 June 19th 06 09:14 PM
Newbie Question - Subtraction Formula Question [email protected] Excel Discussion (Misc queries) 3 May 5th 06 05:50 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM


All times are GMT +1. The time now is 01:43 PM.

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

About Us

"It's about Microsoft Excel"