Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB programming - Managing sheet-2 from sheet-1

Status
Not open for further replies.

Evening

Technical User
Jan 19, 2005
45
0
0
CA
I have 2 worksheets in the workbook, 1.MENU, 2.BASIC DATA

I am in MENU worksheet.(BASIC DATA sheet is hiden)
Double click on OPTION-1 in MENU worksheet initializing VB


Sheets("BASIC DATA").Visible = True
ActiveSheet.Unprotect
Range("D6:G11").Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("D14:D20").Select
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Sheets("MENU").Select
ActiveWindow.SelectedSheets.Visible = False


After this the sheet MENU sheet is hiden, and BASIC DATA sheet appears.
For some reason cells are not unlocked in BASIC DATA sheet, as I expected.

I used password protection manually, but just couldn't get the sintax in macro when i tried to do
with macro. How can i do automatically entering the password
(With password 321, I tried:

cursht = ActiveSheet.Name
Sheets(cursht).Unprotect "321"

didn't work out.

Is it possible that I can't manage the BASIC DATA SHEET from the MENU sheet with VB program?
 



Hi,

When you make the data sheet visible, it is NOT activated or referenced...
Code:
  with Sheets("BASIC DATA")
    .Visible = True
    .Unprotect
    with Range("D6:G11")
      .Locked = False
      .FormulaHidden = False
    end with
    with Range("D14:D20")
      .Locked = False
      .FormulaHidden = False
    end with
    .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
  end with  
'    Sheets("MENU").Select
'    ActiveWindow.SelectedSheets.Visible = False

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Skip


Your suggestion didn't work out. Giving instruction in VB worksheet MENU to change the Protection of some fields in workesheet BASIC DATA. I tried to use some password protection in order to allow some poeple to chnage some data in the worksheet BASIC DATA. This is what i tried:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'1. MENU
'2. BASIC DATA'
If Target.Address = Range("F4").Address Then
Range("psw").Select
End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case psw
'(If password was 7091)'
Case 7091
With Sheets("BASIC DATA")
.Visible = True
.Unprotect "321" '

With Range("D6:G11")
.Locked = False
.FormulaHidden = False
End With
With Range("D14:D20")
.Locked = False
.FormulaHidden = False
End With
.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Sheets("MENU").Select '
ActiveWindow.SelectedSheets.Visible = False '
'Sheets("BASIC DATA).Protect "321"'
Sheets("DATA BASIC").Select
Case Else
Sheets("BASIC DATA").Visible = True
Sheets("BASIC DATA").Select
Sheets("MENU").Select
ActiveWindow.SelectedSheets.Visible = False

End Select
End Sub



I'm not a VB programmer, i just try to use some basic programming in excell in my experience in the machine industry. I'd appreciate any help or suggestion.

Thanks
 



I can't figure outyour code. You have compile errors.

Try this...
Code:
  with Sheets("BASIC DATA")
    .Visible = True
    .Unprotect
    with .Range("D6:G11")
      .Locked = False
      .FormulaHidden = False
    end with
    with .Range("D14:D20")
      .Locked = False
      .FormulaHidden = False
    end with
    .Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
  end with
I failed to reference the ranges BACK to the sheet.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top