Hey guys,
I'm trying to write a couple of really simple macros that will multiply or divide any given cell by 5. So I want to basically do =Formula(C6) to get me C6 x 5. Or to =Formula(D5) to get D5/5.
How would I do this?
Thanks
Hey guys,
I'm trying to write a couple of really simple macros that will multiply or divide any given cell by 5. So I want to basically do =Formula(C6) to get me C6 x 5. Or to =Formula(D5) to get D5/5.
How would I do this?
Thanks
Why would you like to use VBA for that?
It can be done in Excel easaly.
Another suggestion would be.
Record it with the macro-recorder and you get the code.
Notice my main language is not English.
I appreciate it, if you reply on my solution.
If you are satisfied with the solution, please mark the question solved.
You can add reputation by clicking on the star * add reputation.
I'm trying to learn and I can't figure out the syntax to apply an operation to any given cell. What's the notation for cell x?
Code such as the following:
![]()
Please Login or Register to view this content.
I didn't really understand the request. The code would be:
Keep in mind, you need an event to fire the code. Is there something in specific you are trying to work towards, or are you strictly looking for the basics?![]()
Please Login or Register to view this content.
Ok so I tried
Function convert()
convert = ActiveCell * 5
End Function
And it didn't work. I want to be able to click a cell, say with a value of 10, insert it into the convert function, and get 50 as a result. So for example, say cell F6 = 10. In another cell I would input =convert(F6) to get 50 in that cell.
Ok, now I better understand. You are setting up a user defined function.
Try the following code in a standard module
Then, test it in the spreadsheet. In cell A1, enter the number 10. In cell B1, enter the formula =CONVERT(A1)![]()
Please Login or Register to view this content.
Let me know if this is what you were after
Bump
thanks for help
Hm, the function worked fine for me. I wonder if maybe Convert is an existing function in Excel 2007 and not in 2003, and it's causing an issue. Try using the following code (just changed the name). Let me know.
![]()
Please Login or Register to view this content.
Glad to help! Keep us posted with future requests.
@ Oilandgasmonkey
Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
Thanks.
Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks