![]() |
assigning a macro to a cell?
Can I do the following. I am a novice in VBA. I will try to explain t the best of my ability. In Sheet1 I want the code to start in J2 and search down all of the column unti J200. If it finds the words NEED TO PAY, then put a command button o anything that can run an assigned macro in the corresponding colum (K). So if the loop or code finds the words NEED TO PAY in J10 i would put a button or someting in K10 that would run a macro(have th ability to run a macro, don't run now), only if it is clicked. Any help would be wonderful, please let me know, I probably didn't explain very well Thanks jos -- jhahe ----------------------------------------------------------------------- jhahes's Profile: http://www.excelforum.com/member.php...fo&userid=2359 View this thread: http://www.excelforum.com/showthread.php?threadid=46837 |
assigning a macro to a cell?
Just built this in Excel 2000.
It puts in buttons from the Forms Toolbar and places then to the right of the cell in J. It than assigns the macro "Macro3" to the button. The button position is defined by c.Offset(0, 1) The 1 is the next cell to the right, 2 is the 2nd, .... See if this is what you need... Sub MakeButtons() Dim rw As Long, c, firstAddress, x, y With ActiveSheet.Range("J2:J200") Set c = .Find("need to pay", LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do x = c.Offset(0, 1).Top y = c.Offset(0, 1).Left ActiveSheet.Buttons.Add(y, x, 48.75, 13.5).Select Selection.Name = "Button" & c.Row Selection.OnAction = "Macro3" ActiveSheet.Shapes("Button" & c.Row).Select Selection.Characters.Text = "" Set c = .FindNext(c) Loop While Not c Is Nothing And c.Address < firstAddress End If End With Cells(2, 10).Select End Sub -- steveB Remove "AYN" from email to respond "jhahes" wrote in message ... Can I do the following. I am a novice in VBA. I will try to explain to the best of my ability. In Sheet1 I want the code to start in J2 and search down all of the column until J200. If it finds the words NEED TO PAY, then put a command button or anything that can run an assigned macro in the corresponding column (K). So if the loop or code finds the words NEED TO PAY in J10 it would put a button or someting in K10 that would run a macro(have the ability to run a macro, don't run now), only if it is clicked. Any help would be wonderful, please let me know, I probably didn't explain very well Thanks josh -- jhahes ------------------------------------------------------------------------ jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596 View this thread: http://www.excelforum.com/showthread...hreadid=468371 |
assigning a macro to a cell?
P.S.
Your description was clear to me. Especially for a "novice" - well done. The only thing you might have included is whether or not each button gets the same macro or not... And it is recommended that you include which version of Excel you are using... -- steveB Remove "AYN" from email to respond "jhahes" wrote in message ... Can I do the following. I am a novice in VBA. I will try to explain to the best of my ability. In Sheet1 I want the code to start in J2 and search down all of the column until J200. If it finds the words NEED TO PAY, then put a command button or anything that can run an assigned macro in the corresponding column (K). So if the loop or code finds the words NEED TO PAY in J10 it would put a button or someting in K10 that would run a macro(have the ability to run a macro, don't run now), only if it is clicked. Any help would be wonderful, please let me know, I probably didn't explain very well Thanks josh -- jhahes ------------------------------------------------------------------------ jhahes's Profile: http://www.excelforum.com/member.php...o&userid=23596 View this thread: http://www.excelforum.com/showthread...hreadid=468371 |
All times are GMT +1. The time now is 03:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com