Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,143,185 members, 7,780,283 topics. Date: Thursday, 28 March 2024 at 11:44 AM

Command Button On Excel - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Command Button On Excel (1543 Views)

Help On Excel / How Do I Disable The Cancel Button On The Top Corner Of Forms In C#? / Help Me With Code To Disable The Maximize Button On My Jframe (java). (2) (3) (4)

(1) (Reply) (Go Down)

Command Button On Excel by maakano(m): 11:22am On Jul 23, 2008
Can any body help me on how to programm Excel to use Command button to open different workbooks and or sheets

Thanks
Re: Command Button On Excel by javaprince(m): 12:12pm On Jul 26, 2008
sbucareer:


Open your spread sheet and make forms visible. i.e. View - Toolbars - Forms.

Click the button control and position to a desired location on the Sheet interested. To connect it to another sheet on event click. Go to Tools - Macro - Visual Basic Editor and type


Private Sub CommandButton1_Click()
Windows("Filename.xls"wink.Activate
Sheets("Sheet2"wink.Select
End Sub



If the work sheet is in anther file in your physical directory, use this code snipets


Sub Commandbutton1_click()
Dim WbookCheck As Workbook

On Error Resume Next
Set WbookCheck = Workbooks("Filename.xls"wink
On Error Goto 0

If WbookCheck Is Nothing Then 'Closed
Workbooks.Open "C:\Filename.xls"
ElseIf Application. ActiveWorkbook. Name = WbookCheck.Name Then
WbookCheck.Close SaveChanges:=True
Else
WbookCheck.Activate
End If
End Sub



@sbucareer
You are so dynamic. I admire your wealth of knowlege and experience.
Re: Command Button On Excel by sbucareer(f): 5:23pm On Jul 26, 2008

Javaprince thank you. It is not my power it is the power of God. I will still send those things for you.
Re: Command Button On Excel by maakano(m): 7:42pm On Jul 28, 2008
sbucareer thank you very much for this assistance I have not tried because I am seriously busy in the office. As soon as I tried it I will inform you.
Thanks.

(1) (Reply)

Developers, Share Your Github URL! / Which Computer Programming Course Is Relevant For A Microbiologist To Undergo??? / Best Betting Software Created By A Nigerian

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.