I'm new to VBA so not exactly sure how this all works but I've got the jist. I am trying to import data from multiple workbooks into one workbook that is created by the program. I have got the main importing done correctly (although not effeciently) but then one of three things happens: The data is imported into correct places and is fine, the data overlaps after the first set, or only the first set of data is transferred. I just can't work out why!
Do
Filename = InputBox("What is the full path and name of the file?")
Workbooks.Open (Filename)
data_range = InputBox("What is the cell range of the wanted data in the original file? If this is the first set of data, include the titles for reference")
ActiveSheet.Range(data_range).Select
Selection.Copy
ActiveWorkbook.Close
If first = True Then
ActiveSheet.Range("b2").Select
End If
If first = False Then
ActiveSheet.Range("b" & (difference + 3)).Select
End If
ActiveSheet.Paste
ActiveSheet.Range("a1").Select
again = MsgBox("Would you like to import another set of data?", 4)
Call start_cell(range_of_cells, data_range)
first = False
Loop Until again = vbNo
That was the main program. The sub-procedure start_cell is below:
range_of_cells = Split(data_range, ":")
NUMBERS(0) = Right(range_of_cells(0), 2)
NUMBERS(1) = Right(range_of_cells(1), 2)
check = IsNumeric(NUMBERS(0))
If check = False Then
'wrong
End If
check = IsNumeric(NUMBERS(1))
If check = False Then
'wrong
End If
difference = (NUMBERS(1) - NUMBERS(0)) + difference
Any help would be awesome. Also if there are any more effecient ways that'd be great.