Multiply VBA InputBox value (decimal) by cell value (decimal) derived from a Json url Web Query
(Updated) I'm new to VBA and have been trying various things for hours but I can't seem to figure out how to simply multiply a decimal user input of 1.1 by the cell value of C1 (71388.92). Here is what I've tried last:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
End Sub
I get a runtime error '13'- Type mismatch perhaps because cell C1
's value is derived from a json web query. I've tried Variant, Double, Single, Long and Data Types Decimal, Number and Currency.
Download link: https://www.dropbox.com/sh/tg5f2a71k9jy6xq/AACrhI9_6VG8vJkDr0QVCbSUa?dl=0
excel vba excel-vba decimal json-query
|
show 7 more comments
(Updated) I'm new to VBA and have been trying various things for hours but I can't seem to figure out how to simply multiply a decimal user input of 1.1 by the cell value of C1 (71388.92). Here is what I've tried last:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
End Sub
I get a runtime error '13'- Type mismatch perhaps because cell C1
's value is derived from a json web query. I've tried Variant, Double, Single, Long and Data Types Decimal, Number and Currency.
Download link: https://www.dropbox.com/sh/tg5f2a71k9jy6xq/AACrhI9_6VG8vJkDr0QVCbSUa?dl=0
excel vba excel-vba decimal json-query
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
2
It shouldn't matter the source of whereC1
obtained it's value - what matters is the actual value ofC1
. That's the question we need answered.
– K.Dᴀᴠɪs
Nov 20 '18 at 0:14
|
show 7 more comments
(Updated) I'm new to VBA and have been trying various things for hours but I can't seem to figure out how to simply multiply a decimal user input of 1.1 by the cell value of C1 (71388.92). Here is what I've tried last:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
End Sub
I get a runtime error '13'- Type mismatch perhaps because cell C1
's value is derived from a json web query. I've tried Variant, Double, Single, Long and Data Types Decimal, Number and Currency.
Download link: https://www.dropbox.com/sh/tg5f2a71k9jy6xq/AACrhI9_6VG8vJkDr0QVCbSUa?dl=0
excel vba excel-vba decimal json-query
(Updated) I'm new to VBA and have been trying various things for hours but I can't seem to figure out how to simply multiply a decimal user input of 1.1 by the cell value of C1 (71388.92). Here is what I've tried last:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
End Sub
I get a runtime error '13'- Type mismatch perhaps because cell C1
's value is derived from a json web query. I've tried Variant, Double, Single, Long and Data Types Decimal, Number and Currency.
Download link: https://www.dropbox.com/sh/tg5f2a71k9jy6xq/AACrhI9_6VG8vJkDr0QVCbSUa?dl=0
excel vba excel-vba decimal json-query
excel vba excel-vba decimal json-query
edited Nov 21 '18 at 0:07
asked Nov 19 '18 at 23:45
kymadic
34
34
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
2
It shouldn't matter the source of whereC1
obtained it's value - what matters is the actual value ofC1
. That's the question we need answered.
– K.Dᴀᴠɪs
Nov 20 '18 at 0:14
|
show 7 more comments
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
2
It shouldn't matter the source of whereC1
obtained it's value - what matters is the actual value ofC1
. That's the question we need answered.
– K.Dᴀᴠɪs
Nov 20 '18 at 0:14
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
2
2
It shouldn't matter the source of where
C1
obtained it's value - what matters is the actual value of C1
. That's the question we need answered.– K.Dᴀᴠɪs
Nov 20 '18 at 0:14
It shouldn't matter the source of where
C1
obtained it's value - what matters is the actual value of C1
. That's the question we need answered.– K.Dᴀᴠɪs
Nov 20 '18 at 0:14
|
show 7 more comments
3 Answers
3
active
oldest
votes
I think this is your solution:
myValue = InputBox("Prompt", "Title")
Range("C5").Select
ActiveCell.FormulaR1C1 = myValue * Range("C1")
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
add a comment |
Declare as double instead of variant
Dim myValue As Double
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
add a comment |
Found Solution:
The error with the InputBox
accepting a decimal entry lies with the "Thousands Separator" settings and whether you enter a comma or point into the InputBox
. I had my "Thousands Separator" set to use a point .
because I'm working with .csv file exports so it was useful. Either will work but you have to change your Windows decimal symbol settings by going to:
Control Panel > Language > Change date, time, or number formats > Additional Settings > Decimal symbol
.
As for the multiplication part: The original InputBox
returns a string. Using Val()
converts the number string to a number and is the correct VBA script:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = Val(InputBox("Prompt", "Title"))
Range("C5").Value = myValue * Range("C3")
End Sub
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384256%2fmultiply-vba-inputbox-value-decimal-by-cell-value-decimal-derived-from-a-jso%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think this is your solution:
myValue = InputBox("Prompt", "Title")
Range("C5").Select
ActiveCell.FormulaR1C1 = myValue * Range("C1")
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
add a comment |
I think this is your solution:
myValue = InputBox("Prompt", "Title")
Range("C5").Select
ActiveCell.FormulaR1C1 = myValue * Range("C1")
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
add a comment |
I think this is your solution:
myValue = InputBox("Prompt", "Title")
Range("C5").Select
ActiveCell.FormulaR1C1 = myValue * Range("C1")
I think this is your solution:
myValue = InputBox("Prompt", "Title")
Range("C5").Select
ActiveCell.FormulaR1C1 = myValue * Range("C1")
answered Nov 20 '18 at 4:28
ali
387
387
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
add a comment |
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
Thanks but it doesn't work.
– kymadic
Nov 20 '18 at 4:35
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
@kymadic - "it doesn't work" is not a helpful response!
– SJR
Nov 20 '18 at 8:49
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
but i tested this in excel 2016 and it works. can you explain your problem? debug your code step by step (F8) and check variable content.
– ali
Nov 20 '18 at 12:15
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
I tried your code in the "new api version.xlsm" and I still get the same runtime error '13': Type mismatch on the line which contains ActiveCell.FormulaR1C1 = myValue * Range("C1"). The input and output should contain a decimal number. It works with whole numbers but not decimals which are required up to 6 or so decimal points. It doesn't work at all in the previous "preferred version.xlsm".
– kymadic
Nov 20 '18 at 17:58
add a comment |
Declare as double instead of variant
Dim myValue As Double
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
add a comment |
Declare as double instead of variant
Dim myValue As Double
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
add a comment |
Declare as double instead of variant
Dim myValue As Double
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
Declare as double instead of variant
Dim myValue As Double
myValue = InputBox("Prompt", "Title")
Range("C5").Value = myValue * Range("C1")
answered Nov 20 '18 at 11:59
Manoj Babu
312
312
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
add a comment |
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
I've tried Double, Single, Long and Variant. None work and I need to enter numbers to the effect of 0.0012345
– kymadic
Nov 20 '18 at 18:00
add a comment |
Found Solution:
The error with the InputBox
accepting a decimal entry lies with the "Thousands Separator" settings and whether you enter a comma or point into the InputBox
. I had my "Thousands Separator" set to use a point .
because I'm working with .csv file exports so it was useful. Either will work but you have to change your Windows decimal symbol settings by going to:
Control Panel > Language > Change date, time, or number formats > Additional Settings > Decimal symbol
.
As for the multiplication part: The original InputBox
returns a string. Using Val()
converts the number string to a number and is the correct VBA script:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = Val(InputBox("Prompt", "Title"))
Range("C5").Value = myValue * Range("C3")
End Sub
add a comment |
Found Solution:
The error with the InputBox
accepting a decimal entry lies with the "Thousands Separator" settings and whether you enter a comma or point into the InputBox
. I had my "Thousands Separator" set to use a point .
because I'm working with .csv file exports so it was useful. Either will work but you have to change your Windows decimal symbol settings by going to:
Control Panel > Language > Change date, time, or number formats > Additional Settings > Decimal symbol
.
As for the multiplication part: The original InputBox
returns a string. Using Val()
converts the number string to a number and is the correct VBA script:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = Val(InputBox("Prompt", "Title"))
Range("C5").Value = myValue * Range("C3")
End Sub
add a comment |
Found Solution:
The error with the InputBox
accepting a decimal entry lies with the "Thousands Separator" settings and whether you enter a comma or point into the InputBox
. I had my "Thousands Separator" set to use a point .
because I'm working with .csv file exports so it was useful. Either will work but you have to change your Windows decimal symbol settings by going to:
Control Panel > Language > Change date, time, or number formats > Additional Settings > Decimal symbol
.
As for the multiplication part: The original InputBox
returns a string. Using Val()
converts the number string to a number and is the correct VBA script:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = Val(InputBox("Prompt", "Title"))
Range("C5").Value = myValue * Range("C3")
End Sub
Found Solution:
The error with the InputBox
accepting a decimal entry lies with the "Thousands Separator" settings and whether you enter a comma or point into the InputBox
. I had my "Thousands Separator" set to use a point .
because I'm working with .csv file exports so it was useful. Either will work but you have to change your Windows decimal symbol settings by going to:
Control Panel > Language > Change date, time, or number formats > Additional Settings > Decimal symbol
.
As for the multiplication part: The original InputBox
returns a string. Using Val()
converts the number string to a number and is the correct VBA script:
Private Sub CommandButton1_Click()
Dim myValue As Variant
myValue = Val(InputBox("Prompt", "Title"))
Range("C5").Value = myValue * Range("C3")
End Sub
edited Nov 21 '18 at 3:58
answered Nov 21 '18 at 0:00
kymadic
34
34
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53384256%2fmultiply-vba-inputbox-value-decimal-by-cell-value-decimal-derived-from-a-jso%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should watch this series: Excel VBA Introduction Part 1 - Getting Started in the VB Editor.
– TinMan
Nov 19 '18 at 23:51
Your code is valid. What is the problem?
– TinMan
Nov 19 '18 at 23:52
I think you need an error check on the value entered by the user. What if it's alphanumeric? or nothing?
– cybernetic.nomad
Nov 19 '18 at 23:58
I get a Runtime error '13'. Type mismatch perhaps because cell C1's value is derived from a Json web query. I've edited my question to include the query code.
– kymadic
Nov 20 '18 at 0:13
2
It shouldn't matter the source of where
C1
obtained it's value - what matters is the actual value ofC1
. That's the question we need answered.– K.Dᴀᴠɪs
Nov 20 '18 at 0:14