How I Can copy data from the VBA coded hidden sheet without making it visible first? Please Help anyone if can

lovejanu4u

New Member
Joined
Apr 29, 2019
Messages
36
Source Code:
Private Sub CommandButton1_Click()

If TextBox1.Text = Sheets("Admin").Range("E4") Then

If TextBox2.Text = Sheets("Admin").Range("f4") Then

MsgBox "xxxxx now you can access the file"

Application.Visible = True

ActiveWorkbook.Unprotect ("20051982")

Sheets("Emp Status").Visible = True

Sheets("Emp Data").Visible = False



ActiveWorkbook.Protect Password:="20051982"

Unload Me

Else

MsgBox "Check Your Username or Password"



End If

End If



End Sub




Desitnation:

Sub Button5_Click()


Sheets("EMP Data").Select
Range("A1:AS1500").Select
Selection.Copy

Sheets("Information Data").Select
Range("A4").Select
ActiveSheet.Paste


End Sub


Note: I need code to copy from ("EMP Data") to paste destination sheets("Information Data"). I added restriction for the users but I want user to check the copy of information.





 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
As one line...
VBA Code:
Sub Button5_Click()
Sheets("EMP Data").Range("A1:AS1500").Copy Sheets("Information Data").Range("A4")
End Sub
 
Upvote 0
As one line...
VBA Code:
Sub Button5_Click()
Sheets("EMP Data").Range("A1:AS1500").Copy Sheets("Information Data").Range("A4")
End Sub


Hello Mark
Greetings!

Thanks for replying mark, but I have restricted (Sheets ("EMP data")) to certain users and now I want them only get the copy but from restricted sheet.

The restricted sheet is not visible.
 
Upvote 0
The visibilty isn't an issue with the code that I posted.

Yes I restricted them to access those sheet directly, and I am using this method for getting them only the copy. I applied VBAproject password is that an issue I am confused.
 
Upvote 0
If you want the code to only run for the users then you need to put the code within the Username test (or do a new test in the separate code).
Protection won't work with the code as it doesn't interact with the cells.
VBAproject password is that an issue I am confused.
Shouldn't be
 
Upvote 0
Just you can see the error being notified . How i can clear it.
 

Attachments

  • Error.JPG
    Error.JPG
    16.8 KB · Views: 7
Upvote 0
Are you getting that error with the code that I posted or the first code, I don't get that error with the code that I posted (with the button on the Information Data sheet with EMP Data sheet hidden and protected).

.
 
Upvote 0
Also in Macro security on the Developer tab check to see if you have "Trust access to the VBA Project Object Model" checked.
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top