Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, I'm sure this is a really simple one to ask but I'm a VBA newbie! I need my code to recognise which is the current active sheet but I don't know the correct syntax for it within an IF statement. Here is my draft coding: Private Sub CommandButton1_Click() If ActiveSheet = "Sheet 2" OR "Sheet 3" OR "Sheet 6" Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub Also, as an alternative, please could you also help on the correct coding it would be via the Case select method. Thank you. -- Blondegirl ------------------------------------------------------------------------ Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615 View this thread: http://www.excelforum.com/showthread...hreadid=537687 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If Activesheet.Name = "Sheet2" or Activesheet.Name = "Sheet3" then
HTH -- AP "Blondegirl" a écrit dans le message de ... Hello, I'm sure this is a really simple one to ask but I'm a VBA newbie! I need my code to recognise which is the current active sheet but I don't know the correct syntax for it within an IF statement. Here is my draft coding: Private Sub CommandButton1_Click() If ActiveSheet = "Sheet 2" OR "Sheet 3" OR "Sheet 6" Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub Also, as an alternative, please could you also help on the correct coding it would be via the Case select method. Thank you. -- Blondegirl ------------------------------------------------------------------------ Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615 View this thread: http://www.excelforum.com/showthread...hreadid=537687 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For interest, another way
Private Sub CommandButton1_Click() If Not IsError(Application.Match(ActiveSheet.Name, Array("Sheet2", "Sheet3", "Sheet6"))) Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Ardus Petus" wrote in message ... If Activesheet.Name = "Sheet2" or Activesheet.Name = "Sheet3" then HTH -- AP "Blondegirl" a écrit dans le message de ... Hello, I'm sure this is a really simple one to ask but I'm a VBA newbie! I need my code to recognise which is the current active sheet but I don't know the correct syntax for it within an IF statement. Here is my draft coding: Private Sub CommandButton1_Click() If ActiveSheet = "Sheet 2" OR "Sheet 3" OR "Sheet 6" Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub Also, as an alternative, please could you also help on the correct coding it would be via the Case select method. Thank you. -- Blondegirl ------------------------------------------------------------------------ Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615 View this thread: http://www.excelforum.com/showthread...hreadid=537687 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Select Case Activesheet.Name
Case "Sheet2" msgbox "Activesheet is Sheet2" Case "Sheet3" msgbox "Activesheet is Sheet3" Case Else msgbox "Activesheet is neither Sheet2 or Sheet3" End Select -- Regards, Tom Ogilvy "Bob Phillips" wrote: For interest, another way Private Sub CommandButton1_Click() If Not IsError(Application.Match(ActiveSheet.Name, Array("Sheet2", "Sheet3", "Sheet6"))) Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Ardus Petus" wrote in message ... If Activesheet.Name = "Sheet2" or Activesheet.Name = "Sheet3" then HTH -- AP "Blondegirl" a écrit dans le message de ... Hello, I'm sure this is a really simple one to ask but I'm a VBA newbie! I need my code to recognise which is the current active sheet but I don't know the correct syntax for it within an IF statement. Here is my draft coding: Private Sub CommandButton1_Click() If ActiveSheet = "Sheet 2" OR "Sheet 3" OR "Sheet 6" Then frmAddrecord1.Show Else frmAddrecord2.Show End If End Sub Also, as an alternative, please could you also help on the correct coding it would be via the Case select method. Thank you. -- Blondegirl ------------------------------------------------------------------------ Blondegirl's Profile: http://www.excelforum.com/member.php...o&userid=29615 View this thread: http://www.excelforum.com/showthread...hreadid=537687 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy sheet and make new sheet active | Excel Discussion (Misc queries) | |||
Active Cell Copy And Paste Sheet to Sheet | New Users to Excel | |||
Copy my active sheet to a new sheet and open with an input form | Excel Programming | |||
Copy from active sheet and paste into new sheet using info from cell in active | Excel Programming | |||
Recognising '0.00' | Excel Programming |