Ambichamti
06-23-2020, 09:53 AM
This code puts formula in specified range in excel by asking users for formula input by using input box and also for range to put formula in excel by using input box that returns range.
This works fine if we specify range and formula but as if we use cancel it delivers false it gave an error I did a web search for help.
I got a solution that is using result of range input box in variant variable and then using "if type of v as range" as in code.
But v returns empty so I can't set Formulacell range variable as v variant.so this code fails as it exit's sub as in code.
Please give a solution even instead of using variant variable
sub WoVbaAppInputbox
Dim Myformula as string
Dim Formulacell as range
Dim v as variant
Myformula=Application.inputbox(prompt:="Enter formula", _Default:="=SUM(", _Type:=0)
V = Application.inputbox(prompt:="specify range", _Type:=8)
If Not type of v is Range then
Exit sub
Else
Set Formulacell = v
End if
Formulacell.formulalocal= Myformula
End sub
This works fine if we specify range and formula but as if we use cancel it delivers false it gave an error I did a web search for help.
I got a solution that is using result of range input box in variant variable and then using "if type of v as range" as in code.
But v returns empty so I can't set Formulacell range variable as v variant.so this code fails as it exit's sub as in code.
Please give a solution even instead of using variant variable
sub WoVbaAppInputbox
Dim Myformula as string
Dim Formulacell as range
Dim v as variant
Myformula=Application.inputbox(prompt:="Enter formula", _Default:="=SUM(", _Type:=0)
V = Application.inputbox(prompt:="specify range", _Type:=8)
If Not type of v is Range then
Exit sub
Else
Set Formulacell = v
End if
Formulacell.formulalocal= Myformula
End sub