![]() |
print
Hi, all
I am very new to this forum. but i know i can get all my answers here. I have several commands buttons on an excel sheet and when i assigned a hyperlink macro to say, when i click on cmd button A1, it leads me to Sheet2 B2. That's fine. but when i click on cmd button A2, it sends me to Sheet2B2 again. am quite new to VBA, macros and all that stuff and would like to have help for me to have a macro which would enable me to have different worksheet links assigned different command buttons Thanks ruben |
print
Try this
Private Sub CommandButton1_Click() Sheets("Sheet 1").Select End Sub Private Sub CommandButton2_Click() Sheets("Sheet 2").Select End Sub and so on "ruben" wrote: Hi, all I am very new to this forum. but i know i can get all my answers here. I have several commands buttons on an excel sheet and when i assigned a hyperlink macro to say, when i click on cmd button A1, it leads me to Sheet2 B2. That's fine. but when i click on cmd button A2, it sends me to Sheet2B2 again. am quite new to VBA, macros and all that stuff and would like to have help for me to have a macro which would enable me to have different worksheet links assigned different command buttons Thanks ruben |
print
Mark Dullingham wrote:
Try this Private Sub CommandButton1_Click() Sheets("Sheet 1").Select End Sub Private Sub CommandButton2_Click() Sheets("Sheet 2").Select End Sub and so on Hi, all [quoted text clipped - 9 lines] Thanks ruben Thanks Mark for the help. I've tried the code in sheet 1 and it gives me an error message when i runs the macro "subscript put of range" and highlights the "Sheets("Sheet 1").Select". What i understand is that the macro will jump to another worksheet on a button click. But let mre b more precise about my problem. In my excel sheet, Sheet 1 contains several command buttons which i would like to link each of the button to their respective cell in sheet 2. Sheet 2 contains hundreds of invoices, each of them copied under the other and the spacing between the cell to be linked in invoice No2 (F54) is 45 cells below invoice No1. So it goes on F9, F54, F99, etc... Is there a way Dan to link the command buttons to write a macro which will tell the command button1 to go to F9, command button 2 to F54, etc.? If you could get me out of this hell, please. Many thanks ruben -- Message posted via http://www.officekb.com |
print
Sorry Ruben it was late and I didn't try the code first.
Have you tried using hyperlinks instead! "ruben via OfficeKB.com" wrote: Mark Dullingham wrote: Try this Private Sub CommandButton1_Click() Sheets("Sheet 1").Select End Sub Private Sub CommandButton2_Click() Sheets("Sheet 2").Select End Sub and so on Hi, all [quoted text clipped - 9 lines] Thanks ruben Thanks Mark for the help. I've tried the code in sheet 1 and it gives me an error message when i runs the macro "subscript put of range" and highlights the "Sheets("Sheet 1").Select". What i understand is that the macro will jump to another worksheet on a button click. But let mre b more precise about my problem. In my excel sheet, Sheet 1 contains several command buttons which i would like to link each of the button to their respective cell in sheet 2. Sheet 2 contains hundreds of invoices, each of them copied under the other and the spacing between the cell to be linked in invoice No2 (F54) is 45 cells below invoice No1. So it goes on F9, F54, F99, etc... Is there a way Dan to link the command buttons to write a macro which will tell the command button1 to go to F9, command button 2 to F54, etc.? If you could get me out of this hell, please. Many thanks ruben -- Message posted via http://www.officekb.com |
print
Mark Dullingham wrote:
Sorry Ruben it was late and I didn't try the code first. Have you tried using hyperlinks instead! Try this Private Sub CommandButton1_Click() [quoted text clipped - 29 lines] Many thanks ruben Yes i did mark, but i am sure u'll understand that it's really cumbersome for hundreds of invoice. i was just thinking how a macro can help me. pls help if u do know a solution. Many thanks Ruben -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200605/1 |
print
Ruben
I have set up a worksheet and tested the following code and it works for me. If tyour sheets are not named ("Sheet2"( then enter "yoursheetname" in between th (" ") marks in the code Private Sub CommandButton1_Click() Sheets("Sheet2").Select ActiveSheet.Range("F9").Select End Sub Private Sub CommandButton2_Click() Sheets("Sheet2").Select ActiveSheet.Range("F54").Select End Sub Private Sub CommandButton3_Click() Sheets("Sheet2").Select ActiveSheet.Range("F99").Select End Sub Hope this helps "ruben via OfficeKB.com" wrote: Mark Dullingham wrote: Sorry Ruben it was late and I didn't try the code first. Have you tried using hyperlinks instead! Try this Private Sub CommandButton1_Click() [quoted text clipped - 29 lines] Many thanks ruben Yes i did mark, but i am sure u'll understand that it's really cumbersome for hundreds of invoice. i was just thinking how a macro can help me. pls help if u do know a solution. Many thanks Ruben -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200605/1 |
print
Mark Dullingham wrote:
Ruben I have set up a worksheet and tested the following code and it works for me. If tyour sheets are not named ("Sheet2"( then enter "yoursheetname" in between th (" ") marks in the code Private Sub CommandButton1_Click() Sheets("Sheet2").Select ActiveSheet.Range("F9").Select End Sub Private Sub CommandButton2_Click() Sheets("Sheet2").Select ActiveSheet.Range("F54").Select End Sub Private Sub CommandButton3_Click() Sheets("Sheet2").Select ActiveSheet.Range("F99").Select End Sub Hope this helps Sorry Ruben it was late and I didn't try the code first. Have you tried using hyperlinks instead! [quoted text clipped - 12 lines] Many thanks Ruben Perfect Mark. Thanks for kindly testing it before. It's working just fine and you 've relieved me from hours of linking. Cheers ruben -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200605/1 |
All times are GMT +1. The time now is 12:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com