Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default Variable VBA Max Formula


Excel2000

I am trying to insert a formula in a cell after inserting values in other
cells from a userform.

ex:
Do While LFound = False

'Encountered a blank record number (assuming end of list on Temp
Data Collection Sheet)
If IsEmpty(Range("B" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop
LRowNumber = LRow - 1

Range("K" & LRowNumber).Value = tbUV1.Value
Range("L" & LRowNumber).Value = tbUV2.Value
Range("M" & LRowNumber).Value = tbUV0.Value
Range("N" & LRowNumber).Value = tbUV3.Value
Range("O" & LRowNumber).Value = tbUV4.Value

I want to insert "=Max(K:O & LRowNumber)" into "W & LRowNumber"

I have tried:
Cells(LRowNumber, 17).Formula = "=MAX(K:O" & LRowNumber & ")"
but the cell (W & LRowNumber) on the sheet has formula "=Max(K:O11)" 11
being the current row number.

Please help
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Variable VBA Max Formula

from
Cells(LRowNumber, 17).Formula = "=MAX(K:O" & LRowNumber & ")"

to
Cells(LRowNumber, 17).Formula = "=MAX(K" & LRowNumber & _
":O" & LRowNumber & ")"


"Gizmo" wrote:


Excel2000

I am trying to insert a formula in a cell after inserting values in other
cells from a userform.

ex:
Do While LFound = False

'Encountered a blank record number (assuming end of list on Temp
Data Collection Sheet)
If IsEmpty(Range("B" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop
LRowNumber = LRow - 1

Range("K" & LRowNumber).Value = tbUV1.Value
Range("L" & LRowNumber).Value = tbUV2.Value
Range("M" & LRowNumber).Value = tbUV0.Value
Range("N" & LRowNumber).Value = tbUV3.Value
Range("O" & LRowNumber).Value = tbUV4.Value

I want to insert "=Max(K:O & LRowNumber)" into "W & LRowNumber"

I have tried:
Cells(LRowNumber, 17).Formula = "=MAX(K:O" & LRowNumber & ")"
but the cell (W & LRowNumber) on the sheet has formula "=Max(K:O11)" 11
being the current row number.

Please help

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,344
Default Variable VBA Max Formula

Hi all,

For what its worth you can simplify the code to

Cells(LRowNumber, 17) = "=MAX(K" & LRowNumber & ":O" & LRowNumber & ")"

Which technically means that the code will run faster, which probably is not
a big deal.

--
Cheers,
Shane Devenshire
Microsoft Excel MVP
Join http://setiathome.berkeley.edu/ and download a free screen saver to
help seach for life out there...


"Joel" wrote:

from
Cells(LRowNumber, 17).Formula = "=MAX(K:O" & LRowNumber & ")"

to
Cells(LRowNumber, 17).Formula = "=MAX(K" & LRowNumber & _
":O" & LRowNumber & ")"


"Gizmo" wrote:


Excel2000

I am trying to insert a formula in a cell after inserting values in other
cells from a userform.

ex:
Do While LFound = False

'Encountered a blank record number (assuming end of list on Temp
Data Collection Sheet)
If IsEmpty(Range("B" & LRow).Value) = True Then
LFound = True
End If

LRow = LRow + 1
Loop
LRowNumber = LRow - 1

Range("K" & LRowNumber).Value = tbUV1.Value
Range("L" & LRowNumber).Value = tbUV2.Value
Range("M" & LRowNumber).Value = tbUV0.Value
Range("N" & LRowNumber).Value = tbUV3.Value
Range("O" & LRowNumber).Value = tbUV4.Value

I want to insert "=Max(K:O & LRowNumber)" into "W & LRowNumber"

I have tried:
Cells(LRowNumber, 17).Formula = "=MAX(K:O" & LRowNumber & ")"
but the cell (W & LRowNumber) on the sheet has formula "=Max(K:O11)" 11
being the current row number.

Please help

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
DDE formula with variable Bruce Excel Worksheet Functions 0 November 16th 07 09:03 AM
Variable within a formula Tom Melosi Excel Worksheet Functions 4 August 21st 07 04:07 AM
Using a variable in a formula [email protected] Excel Discussion (Misc queries) 1 December 29th 06 11:46 AM
Using a variable in a VBA formula Colin Vicary Excel Discussion (Misc queries) 3 November 8th 05 11:39 AM
Using a second variable within a formula... Ed Anton Excel Discussion (Misc queries) 2 February 18th 05 11:51 AM


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