Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The right hand side of the expression below returns a Range that in my
case will always be the value of the last cell in the column DueDateColumn ..... Dim DueDate as Date Set DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp) ..... How can I stuff this value into the DueDate variable??????? I appreciate your patience with me and thanks for you help in advance, /mark |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mark,
Try: DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value --- Regards, Norman "Mark Dvorkin" wrote in message ... The right hand side of the expression below returns a Range that in my case will always be the value of the last cell in the column DueDateColumn ..... Dim DueDate as Date Set DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp) ..... How can I stuff this value into the DueDate variable??????? I appreciate your patience with me and thanks for you help in advance, /mark |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Norman,
first of all: thanks for your patience! the call DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value is within a function which knows which sheet is active, i.e. I'm passing in the sheet name to it. For some reason at this line my function blows up. If I declare Dim DueDateR as Range and Set DueDateR = Cells(Rows.Count, DueDateColumn).End(xlUp) the value I find in the DueDateR is the name of the last Sheet in that Workbook! Do I need (and if so then how) to explicitly tell the Cells method which Sheet it has to act upon? Thanks a lot, /mark Norman Jones wrote: Hi Mark, Try: DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value --- Regards, Norman "Mark Dvorkin" wrote in message ... The right hand side of the expression below returns a Range that in my case will always be the value of the last cell in the column DueDateColumn .... Dim DueDate as Date Set DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp) .... How can I stuff this value into the DueDate variable??????? I appreciate your patience with me and thanks for you help in advance, /mark |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mark,
If the Cells property is not explicitly qualified, it will be implicitly qualified to refer to the active sheet (unless the code is in a sheet module, in which case the qualification will be to the sheet holding the code). Try, therefore, something like: Dim SH As Worksheet Set SH = ActiveWorkbook.Sheets(ShName) DueDate =SH.Cells(Rows.Count, DueDateColumn).End(xlUp).Value where ShName is the passed sheet name. --- Regards, Norman "Mark Dvorkin" wrote in message ... Norman, first of all: thanks for your patience! the call DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value is within a function which knows which sheet is active, i.e. I'm passing in the sheet name to it. For some reason at this line my function blows up. If I declare Dim DueDateR as Range and Set DueDateR = Cells(Rows.Count, DueDateColumn).End(xlUp) the value I find in the DueDateR is the name of the last Sheet in that Workbook! Do I need (and if so then how) to explicitly tell the Cells method which Sheet it has to act upon? Thanks a lot, /mark Norman Jones wrote: Hi Mark, Try: DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value --- Regards, Norman |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Public Function MyFunction(shName as String, DueDateColumn as Long)
Dim DueDateR as Range Dim DueDate as Date Set DueDateR = Worksheets(shName).Cells( _ Rows.Count, DueDateColumn).End(xlUp) DueDate = DueDateR.Value -- Regards, Tom Ogilvy "Mark Dvorkin" wrote in message ... Norman, first of all: thanks for your patience! the call DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value is within a function which knows which sheet is active, i.e. I'm passing in the sheet name to it. For some reason at this line my function blows up. If I declare Dim DueDateR as Range and Set DueDateR = Cells(Rows.Count, DueDateColumn).End(xlUp) the value I find in the DueDateR is the name of the last Sheet in that Workbook! Do I need (and if so then how) to explicitly tell the Cells method which Sheet it has to act upon? Thanks a lot, /mark Norman Jones wrote: Hi Mark, Try: DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value --- Regards, Norman "Mark Dvorkin" wrote in message ... The right hand side of the expression below returns a Range that in my case will always be the value of the last cell in the column DueDateColumn ..... Dim DueDate as Date Set DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp) ..... How can I stuff this value into the DueDate variable??????? I appreciate your patience with me and thanks for you help in advance, /mark |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the suggested qualification did the job!
As a C/C++ programmer I'm a beginner here. I believed my code is in the WorkBook module, not any more ... Where it supposed to be, what is the right place for it or what is the best place for it. How to check where is my code? Thanks for all your help, deeply indebted /mark Norman Jones wrote: Hi Mark, If the Cells property is not explicitly qualified, it will be implicitly qualified to refer to the active sheet (unless the code is in a sheet module, in which case the qualification will be to the sheet holding the code). Try, therefore, something like: Dim SH As Worksheet Set SH = ActiveWorkbook.Sheets(ShName) DueDate =SH.Cells(Rows.Count, DueDateColumn).End(xlUp).Value where ShName is the passed sheet name. --- Regards, Norman "Mark Dvorkin" wrote in message ... Norman, first of all: thanks for your patience! the call DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value is within a function which knows which sheet is active, i.e. I'm passing in the sheet name to it. For some reason at this line my function blows up. If I declare Dim DueDateR as Range and Set DueDateR = Cells(Rows.Count, DueDateColumn).End(xlUp) the value I find in the DueDateR is the name of the last Sheet in that Workbook! Do I need (and if so then how) to explicitly tell the Cells method which Sheet it has to act upon? Thanks a lot, /mark Norman Jones wrote: Hi Mark, Try: DueDate = Cells(Rows.Count, DueDateColumn).End(xlUp).Value --- Regards, Norman |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Mark,
I would refer you to Chip Pearson's comprehensive treatment of this precise issue at: http://www.cpearson.com/excel/codemods.htm --- Regards, Norman "Mark Dvorkin" wrote in message ... the suggested qualification did the job! As a C/C++ programmer I'm a beginner here. I believed my code is in the WorkBook module, not any more ... Where it supposed to be, what is the right place for it or what is the best place for it. How to check where is my code? Thanks for all your help, deeply indebted /mark |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Man!
you have answers for everything and right on the button ... Chip Pearson's site is great. Thanks again, I'm all set for the rest of the night. /mark. Norman Jones wrote: Hi Mark, I would refer you to Chip Pearson's comprehensive treatment of this precise issue at: http://www.cpearson.com/excel/codemods.htm --- Regards, Norman "Mark Dvorkin" wrote in message ... the suggested qualification did the job! As a C/C++ programmer I'm a beginner here. I believed my code is in the WorkBook module, not any more ... Where it supposed to be, what is the right place for it or what is the best place for it. How to check where is my code? Thanks for all your help, deeply indebted /mark |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unable to cast com object (interop) | Excel Discussion (Misc queries) | |||
How do I cast time when the total exceeds 24 hours | Excel Discussion (Misc queries) | |||
CAST Function | Excel Discussion (Misc queries) | |||
Help with MSQuery & CAST function | Excel Programming | |||
Need to cast OleObject to CombBbox | Excel Programming |