jayneecm
New Member
- Joined
- Oct 22, 2024
- Messages
- 3
- Office Version
- Prefer Not To Say
- Platform
- Windows
Morning Everyone
I'm new to this forum and hoping someone can help me. I'm self taught with VBA, I have a document with VBA code that updates information onto another workbook, but the other workbook is shared and therefore sometimes can be read only. I would like to incorporate a warning message that tells the user that it is Read Only so they know not to continue to upload the info. I have tried everything so far but the document just keeps opening without a warning message. can anyone help?
Here is my code:
I'm new to this forum and hoping someone can help me. I'm self taught with VBA, I have a document with VBA code that updates information onto another workbook, but the other workbook is shared and therefore sometimes can be read only. I would like to incorporate a warning message that tells the user that it is Read Only so they know not to continue to upload the info. I have tried everything so far but the document just keeps opening without a warning message. can anyone help?
Here is my code:
VBA Code:
Sub another_workbook()
Dim wbMaster As Workbook
Dim wbLocal As Workbook
Dim masterNextRow As Long
Set wbLocal = ThisWorkbook
Set wbMaster = Workbooks.Open("I:\Global\Figures\Forecasting and Invoicing MASTER.xlsm")
masterNextRow = wbMaster.Worksheets("Invoicing").Range("A" & wbMaster.Worksheets("Invoicing").Rows.Count).End(xlUp).Offset(1).Row
Worksheets("Invoicing").Unprotect "1312"
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 1).Value = wbLocal.Worksheets("Placement Form").Range("C3").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 2).Value = wbLocal.Worksheets("Placement Form").Range("I3").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 3).Value = wbLocal.Worksheets("Placement Form").Range("N3").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 4).Value = wbLocal.Worksheets("Placement Form").Range("F5").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 5).Value = wbLocal.Worksheets("Placement Form").Range("F9").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 6).Value = wbLocal.Worksheets("Placement Form").Range("F11").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 7).Value = wbLocal.Worksheets("Placement Form").Range("F19").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 8).Value = wbLocal.Worksheets("Placement Form").Range("F27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 9).Value = wbLocal.Worksheets("Placement Form").Range("H27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 10).Value = wbLocal.Worksheets("Placement Form").Range("A27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 11).Value = wbLocal.Worksheets("Placement Form").Range("C27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 12).Value = wbLocal.Worksheets("Placement Form").Range("H27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 13).Value = wbLocal.Worksheets("Placement Form").Range("M27").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 14).Value = wbLocal.Worksheets("Placement Form").Range("F38").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 15).Value = wbLocal.Worksheets("Placement Form").Range("N38").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 16).Value = wbLocal.Worksheets("Placement Form").Range("C32").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 17).Value = wbLocal.Worksheets("Placement Form").Range("D99").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 19).Value = wbLocal.Worksheets("Placement Form").Range("M95").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 21).Value = wbLocal.Worksheets("Placement Form").Range("D95").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 20).Value = wbLocal.Worksheets("Placement Form").Range("M97").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 24).Value = wbLocal.Worksheets("Placement Form").Range("D97").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 29).Value = wbLocal.Worksheets("Placement Form").Range("F36").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 30).Value = wbLocal.Worksheets("Placement Form").Range("F17").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 31).Value = wbLocal.Worksheets("Placement Form").Range("F13").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 32).Value = wbLocal.Worksheets("Placement Form").Range("F15").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 33).Value = wbLocal.Worksheets("Placement Form").Range("F40").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 34).Value = wbLocal.Worksheets("Placement Form").Range("M21").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 35).Value = wbLocal.Worksheets("Placement Form").Range("N40").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 36).Value = wbLocal.Worksheets("Placement Form").Range("H32").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 37).Value = wbLocal.Worksheets("Placement Form").Range("L32").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 38).Value = wbLocal.Worksheets("Placement Form").Range("F34").Value
wbMaster.Worksheets("Invoicing").Cells(masterNextRow, 39).Value = wbLocal.Worksheets("Placement Form").Range("K34").Value
Worksheets("Invoicing").Protect "1312"
MsgBox "Input saved."
End Sub
Last edited by a moderator: