Sending data to another closed excel file with a command button

Tej92

Board Regular
Joined
Sep 27, 2022
Messages
73
Office Version
  1. 365
Platform
  1. Windows
Hello all, I'm trying to send data to another file that is closed and on a different drive (G:\) included in the following code:

Private Sub CommandButton3_Click()
x = Sheets("LEG").Range("action_required1")
With Sheets("Actions")
Set rngfind = .Cells.Find(x, , , 1)
rngfind.Offset(, 3) = Date
End With
Range("I22:O22").Value = ""
End Sub

for now it's creating an output on the same file but different sheet, I'd like it to also do the same but on a different file on the server drive G.
thank you
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Managed to sort it myself with the code below, thanks to everyone who looked and might be working on it now.



VBA Code:
Sub SaveDataMasterWorkbook()
Dim wbMaster As Workbook
Dim wbLocal As Workbook
Dim masterNextRow As Long

Set wbLocal = ThisWorkbook

Set wbMaster = Workbooks.Open("G:\6S data\data.xlsx")
masterNextRow = wbMaster.Worksheets("Data").Range("A" & wbMaster.Worksheets("Data").Rows.Count).End(xlUp).Offset(1).Row

wbMaster.Worksheets("data").Cells(masterNextRow, 1).Value = wbLocal.Worksheets("LEG").Range("action_required1").Value
wbMaster.Worksheets("data").Cells(masterNextRow, 2).Value = wbLocal.Worksheets("LEG").Range("action_date").Value
wbMaster.Close True

MsgBox "Input Saved"
End Sub
 
Last edited by a moderator:
Upvote 0
Solution

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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