Problem with formula in VBA

EssKayKay

Well-known Member
Joined
Jan 5, 2003
Messages
504
Office Version
  1. 2007
Platform
  1. Windows
I have a formula in cell V16 I call in a VBA routine. However, if possible I’d rather just include the formula directly in the VBA code.

Here’s the formula in cell V16 –
Rich (BB code):
=ROUNDUP(MAX(PmtNo)/periods_per_year,0)+33

Here’s a portion of the VBA code –
Rich (BB code):
Range("S34:S" & Range("V16").Value).Select

I tried this but apparently VBA does not like the direct formula –

1st Test –
Rich (BB code):
Range("S34:S" & ROUNDUP(MAX(PmtNo)/periods_per_year,0)+33).Select

2nd Test –
Rich (BB code):
Dim EndTotal As String
EndTotal = RoundUp(Max(PmtNo) / periods_per_year, 0) + 33
Range("S34:S" & EndTotal).Select

Thanks for viewing,
Steve K.
 
Try this:

VBA Code:
  Dim EndTotal As Long
  EndTotal = Evaluate("RoundUp(Max(PmtNo) / periods_per_year, 0) + 33")
  Range("S34:S" & EndTotal).Select
 
Upvote 0
Solution
Try this:

VBA Code:
  Dim EndTotal As Long
  EndTotal = Evaluate("RoundUp(Max(PmtNo) / periods_per_year, 0) + 33")
  Range("S34:S" & EndTotal).Select
That did it Dante - much appreciated. . .
Steve
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top