Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Want to use standard excel functions in vb

I have a worksheet containing a list of items that ore of interest to me.
Periodically , I want to add to the list or modify one of the items in the
list.
Each item has an item ID in Col 1 and 'many' other bits of info (text,
numeric, dates) in subsequent columns

I built a user form in VB to pull info into the form from the indicated row
of the db and put it back into the DB as an indicated row.

In order to set the item ID of a new item, I want to get the maxvalue for
all current items.

I wanted to use the following code:

InitID.text = max(Worksheets("OppDB").cells(a1:a65535))

Where InitID is the name of the textbox in my form containing the Initiative
ID, and OppDB is the worksheet within the workbook that holds all data on the
set of initiatives I'm tracking.

I suppose I could do this in a loop, but, since excel has a function that
returns the max value found in a range (a1:aN) I thought this would work.
There are many other excel functions that I might want to use within VB --
what am I missing about how to do this (I know - the answer is probably
obvious).

TIA
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Want to use standard excel functions in vb

Mark,

Please try:

Application.WorkbookFunction.Max(...)

Bill

"Mark" wrote in message
...
I have a worksheet containing a list of items that ore of interest to me.
Periodically , I want to add to the list or modify one of the items in the
list.
Each item has an item ID in Col 1 and 'many' other bits of info (text,
numeric, dates) in subsequent columns

I built a user form in VB to pull info into the form from the indicated
row
of the db and put it back into the DB as an indicated row.

In order to set the item ID of a new item, I want to get the maxvalue for
all current items.

I wanted to use the following code:

InitID.text = max(Worksheets("OppDB").cells(a1:a65535))

Where InitID is the name of the textbox in my form containing the
Initiative
ID, and OppDB is the worksheet within the workbook that holds all data on
the
set of initiatives I'm tracking.

I suppose I could do this in a loop, but, since excel has a function that
returns the max value found in a range (a1:aN) I thought this would work.
There are many other excel functions that I might want to use within VB --
what am I missing about how to do this (I know - the answer is probably
obvious).

TIA
Mark



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Want to use standard excel functions in vb

Thanks, Bill.

Here's the statement I used:

InitID.Text =
Application.WorkbookFunction.Max(Worksheets("OppDB ").Cells(a1:a200))

I'm (still) getting a compile error ("Expected list separator or )" )with
the ":" highlited. Probably a bone head error :-).

"Bill James" wrote:

Mark,

Please try:

Application.WorkbookFunction.Max(...)

Bill

"Mark" wrote in message
...
I have a worksheet containing a list of items that ore of interest to me.
Periodically , I want to add to the list or modify one of the items in the
list.
Each item has an item ID in Col 1 and 'many' other bits of info (text,
numeric, dates) in subsequent columns

I built a user form in VB to pull info into the form from the indicated
row
of the db and put it back into the DB as an indicated row.

In order to set the item ID of a new item, I want to get the maxvalue for
all current items.

I wanted to use the following code:

InitID.text = max(Worksheets("OppDB").cells(a1:a65535))

Where InitID is the name of the textbox in my form containing the
Initiative
ID, and OppDB is the worksheet within the workbook that holds all data on
the
set of initiatives I'm tracking.

I suppose I could do this in a loop, but, since excel has a function that
returns the max value found in a range (a1:aN) I thought this would work.
There are many other excel functions that I might want to use within VB --
what am I missing about how to do this (I know - the answer is probably
obvious).

TIA
Mark




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Want to use standard excel functions in vb

Dim myRange As Range
Set myRange = Worksheets("OppDB").Range("A1:A200")
InitID.Text = Application.WorksheetFunction.Max(myRange)

Do the WorksheetFunction on a variable
Mike F
"Mark" wrote in message
...
Thanks, Bill.

Here's the statement I used:

InitID.Text =
Application.WorkbookFunction.Max(Worksheets("OppDB ").Cells(a1:a200))

I'm (still) getting a compile error ("Expected list separator or )" )with
the ":" highlited. Probably a bone head error :-).

"Bill James" wrote:

Mark,

Please try:

Application.WorkbookFunction.Max(...)

Bill

"Mark" wrote in message
...
I have a worksheet containing a list of items that ore of interest to
me.
Periodically , I want to add to the list or modify one of the items in
the
list.
Each item has an item ID in Col 1 and 'many' other bits of info (text,
numeric, dates) in subsequent columns

I built a user form in VB to pull info into the form from the indicated
row
of the db and put it back into the DB as an indicated row.

In order to set the item ID of a new item, I want to get the maxvalue
for
all current items.

I wanted to use the following code:

InitID.text = max(Worksheets("OppDB").cells(a1:a65535))

Where InitID is the name of the textbox in my form containing the
Initiative
ID, and OppDB is the worksheet within the workbook that holds all data
on
the
set of initiatives I'm tracking.

I suppose I could do this in a loop, but, since excel has a function
that
returns the max value found in a range (a1:aN) I thought this would
work.
There are many other excel functions that I might want to use within
VB --
what am I missing about how to do this (I know - the answer is
probably
obvious).

TIA
Mark






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 Standard Colours Irm Excel Discussion (Misc queries) 1 October 7th 07 12:31 PM
Three new functions that should be part of your standard set Darren Oakey Excel Worksheet Functions 4 May 12th 06 11:56 PM
Can you set up Excel to automatically add a standard footer? James Excel Discussion (Misc queries) 3 April 5th 06 12:01 PM
Standard deviations in Excel Fred Zack Charts and Charting in Excel 2 June 15th 05 01:19 AM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM


All times are GMT +1. The time now is 09:06 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"