Saturday, December 5, 2009

How to write macros in Microsoft Excel to perform simple decision based?

Hi there,



I wish I could find "devilishblueyes" who answer my question on the first time. From your answer, you seem to be very good at it. I



However, your answer is only work with number 2 as a correct answer, if I change the correct answer to 3 with some adjustment in commands, I could not get it done the way it should be.



so I hope that you can show me again how to build a macro for the cell to go to specific plance if I have numbers from 1 to 4.



Thanks a lot for your help,



How to write macros in Microsoft Excel to perform simple decision based?paramount theater



One of the easiest ways to move to a specific cell quickly, without the need for writing a macro is to select the cell(s) that you want to move to and give it a name, whether its one cell or a range. So, say your number if cell d5, that cell reference will appear in the name box, left side of the formula bar. Just type in a name and Enter. Now move back to A1 and any time you want to get to that particular cell, click on downward arrow to side of name box and click on the name and you are there instantly. Great for moving around large spreadsheets quickly and also of course using a name as opposed to cell reference in formulae/functions means you don't need to use absolutes.



If you really want a macro, Tools, Macro, Record Macro to display macro toolbar in your worksheet and then move to your cell, or perhaps it was an if function that was set up for you. However, move through the procedure then stop the macro running. If you draw a button, right button of mouse on it to add text and colour then assign the macro to it, each time you click on the button to run the macro, quicker than using shortcut keys or going to long way round.



How to write macros in Microsoft Excel to perform simple decision based?theatre opera theater



Yeah, I'll help you on it. You'll have to refresh my memory a little on what you were trying to do. I can't remember the exact question and from your detail on this one I'm not totally sure what you are trying to do.



It doesn't sound like it should be too hard to do. Feel free to send me a message. I have my profile set up so people can email me. And if you haven't already added me as a contact, then you might want to do that.



You probably might want to create a Boolean variable that evaluates to True or False if the number is between 1 and 4.



With numbers a lot of times you have to do several checks. First you might need to check that it is a number with IsNumeric. Then if you need an integer, you might want to compare the Fix of a number to see if they evaluate the same. If they do, then it is an integer. Then you'll probably want to check that it is withing the specified range of 1 to 4. With something like:



Dim MyCheck As Boolean



Dim MyNum



Dim MyNum2 As Double



MyCheck = False



'Checks if it is a number



If IsNumeric(MyNum) = True Then



'Turns the data into a number type if it is a number



MyNum2 = MyNum



'Checks if the number is an integer



If MyNum2 = Fix(MyNum2) Then



'Checks to see if it is a value in the specified range



If 1%26lt;= MyNum2 %26lt;= 4 Then



MyCheck = True



End If



End If



End If

No comments:

Post a Comment

 
Ltd