message box to apply to range

Rogerisit

Board Regular
Joined
Oct 20, 2016
Messages
70
Office Version
  1. 2019
Hi all,

VBA question. I need to use more than one exchange rate, so I have a message box as I want manual input of rates for Euros, however at the moment the box comes up for every line of euros. Can you please help so I only have to input rate once.

VBA Code:
'tax rate
For I = 2 To lastrow1
If SOP.Range("a" & I).Value <> "" Then
If SOP.Range("E" & I) Like "*GBP*" Then
xrate = "'1."
SOP.Range("E" & I).Offset(0, 6) = xrate
Else
myInputBoxVariable = Application.InputBox("Current EUR Exchange Rate?", "Please Enter Rate", , , , , , "2")
SOP.Range("E" & I).Offset(0, 6) = myInputBoxVariable
End If
End If
Next I
 
Last edited by a moderator:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Hi
try changing this line

VBA Code:
myInputBoxVariable = Application.InputBox("Current EUR Exchange Rate?", "Please Enter Rate", , , , , , "2")

to this

VBA Code:
If Len(myInputBoxVariable) = 0 Then myInputBoxVariable = Application.InputBox("Current EUR Exchange Rate?", "Please Enter Rate", , , , , , "2")

and see if does what you want

Dave
 
Upvote 0
Solution
Edit: I got interrupted while composing my post so missed Dave's post which is basically the same as my proposal.
Anyway, I'll leave my post for the other two points I made as well. :)

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊

Try making this change in your code.

Rich (BB code):
myInputBoxVariable = Application.InputBox("Current EUR Exchange Rate?", "Please Enter Rate", , , , , , "2")
If IsEmpty(myInputBoxVariable) Then myInputBoxVariable = Application.InputBox("Current EUR Exchange Rate?", "Please Enter Rate", , , , , , 2)
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,822
Members
449,469
Latest member
Kingwi11y

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