Greetings all... I have a subroutine that opens a 'data file' and moves the data from the current workbook to sheet 1 of the data file and then closes the data file.
I have a similar routine that does the opposite.
The idea is that I have a single file hidden from the users (read our sales manager who doesn't understand computers) that the spreadsheet draws from each time it's opened. Also, I have an 'edit' function where the user can change this data, or add to it, and it will save back to the original data file.
The first bit of code works great;
So, I figured that I'd do the reverse when I wanted to save... (note... the msgbox()'s are there to see that the code was working... msgbox("hi") and msgbox("hi2") show up, but msgbox("hi1.5") never shows up...
Any ideas??
I have a similar routine that does the opposite.
The idea is that I have a single file hidden from the users (read our sales manager who doesn't understand computers) that the spreadsheet draws from each time it's opened. Also, I have an 'edit' function where the user can change this data, or add to it, and it will save back to the original data file.
The first bit of code works great;
Code:
Sub GetCustData()
Dim Target_Workbook As Workbook
Dim Source_Workbook As Workbook
Dim Source_Path As String
Dim numrows As Long
Dim i As Integer
Dim j As Integer
'Application.ScreenUpdating = False
Set Target_Workbook = ThisWorkbook
Source_Path = "B:\Current Jobs\Customers\ForQuotes.xlsx"
Set Source_Workbook = Workbooks.Open(Source_Path)
numrows = Source_Workbook.Sheets(1).Cells(1, 2)
For i = 1 To 16
For j = 1 To numrows
Target_Workbook.Sheets("Lookups").Cells(j + 1, i) = Source_Workbook.Sheets(1).Cells(j + 1, i)
Next j
Next i
Source_Workbook.Close False
'Application.ScreenUpdating = True
End Sub
So, I figured that I'd do the reverse when I wanted to save... (note... the msgbox()'s are there to see that the code was working... msgbox("hi") and msgbox("hi2") show up, but msgbox("hi1.5") never shows up...
Any ideas??
Code:
Sub UpdateDataSource()
'this does the opposite of what the code on the button does
'the target is the this worksheet, the source is data file
Dim Target_Workbook As Workbook
Dim Source_Workbook As Workbook
Dim Source_Path As String
Dim numrows As Long
Dim i As Integer
Dim j As Integer
i = 0
j = 0
'Application.ScreenUpdating = False
Set Target_Workbook = ThisWorkbook
Source_Path = "B:\Current Jobs\Customers\ForQuotes.xlsx"
Set Source_Workbook = Workbooks.Open(Source_Path)
MsgBox ("hi")
numrows = Target_Workbook.Sheets(1).Cells(1, 1)
For i = 1 To 16
For j = 1 To numrows
'MsgBox ("I is " & i & " J is " & j)
MsgBox ("hi 1.5")
Source_Workbook.Sheets(1).Cells(j + 1, i) = Target_Workbook.Sheets("Lookups").Cells(j + 1, i)
Next j
Next i
MsgBox ("hi 2")
Source_Workbook.Save
Source_Workbook.Close False
'Application.ScreenUpdating = True
End Sub