ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Some Basic Doubts in Excel Macro (https://www.excelbanter.com/excel-programming/323623-some-basic-doubts-excel-macro.html)

Manu

Some Basic Doubts in Excel Macro
 
Iam a Leaner of excel macro by using the examples in this
News group because of that i get some simple but serious
doubts some times

I have some more doubts in macro CAN YOU HELP ME please!!


1) Is it possibe to activate an Userform or List Box by
hitting one Key, (in Foxpro it is ONKEY Label...")

2) while giving conditions we use
" if a = "xxx" then ....." etc .....

but how to say
"if a (isnot equal) "xxx" ......"
( other than "else" ..... Condition)

3) while giving conditions we use "if ... then ...
endif ..."statements is it possible for using one
more "if .. then.. endif"
statement in between that statement , if yes how
many "endif" we have to use at the end

PLEASE GIVE ME SOME EXAMPLES ALSO


Tks & regards


Jan Karel Pieterse

Some Basic Doubts in Excel Macro
 
Hi Manu,

1) Is it possibe to activate an Userform or List Box by
hitting one Key, (in Foxpro it is ONKEY Label...")


If your sub that shows the form is called "SubThatShowsTheForm", then
this codeline will attach that sub to control-shift-s:

Application.Onkey "^+s", "SubThatShowsTheForm"

2) while giving conditions we use
" if a = "xxx" then ....." etc .....


but how to say
"if a (isnot equal) "xxx" ......"
( other than "else" ..... Condition)


If a < "xxx" Then


3) while giving conditions we use "if ... then ...
endif ..."statements is it possible for using one
more "if .. then.. endif"
statement in between that statement , if yes how
many "endif" we have to use at the end


You can nest them:

If A=1 Then
If a=2 Then
Msgbox "A= 2"
Else
Msgbox "A is 1"
End If
Else
Msgbox "A is neither 1 nor 2"
End If

Or:

If A=1 Then
Msgbox "A is 1"
ElseIf a=2 Then
Msgbox "A= 2"
Else
Msgbox "A is neither 1 nor 2"
End If

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com



All times are GMT +1. The time now is 07:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com