Dear Excel and VBA experts,
As of recently I have compiled a piece of VBA coding and I could use some fine tuning in it. Perhaps some help can be provided here. I’ll further explain the case and my vision on how I would like to have it work.
Case:
I have one source spreadsheet in which there are an undefined number of columns. These columns should contain the data of around 15-50 target spreadsheets. The target spreadsheets have a certain CONSISTENT (they are all the same) lay-out to make them quite easy to fill in and read.
In the end each of the target spreadsheets should have the data filled in their own column in the source spreadsheet. The current code does this perfectly well, except for one problem. It fills it in a single column and overwrites this column when the next file is opened/selected.
Vision:
I would like that the VBA recognizes that the, in the code, D column is full and uses the E and at the selection of the third document the F column or either a selection in which I could tell, before the import of information begins, which column should be used.
I would like to thank you in advance for helping me.
Best regards,
Pezmerga
As of recently I have compiled a piece of VBA coding and I could use some fine tuning in it. Perhaps some help can be provided here. I’ll further explain the case and my vision on how I would like to have it work.
Case:
I have one source spreadsheet in which there are an undefined number of columns. These columns should contain the data of around 15-50 target spreadsheets. The target spreadsheets have a certain CONSISTENT (they are all the same) lay-out to make them quite easy to fill in and read.
In the end each of the target spreadsheets should have the data filled in their own column in the source spreadsheet. The current code does this perfectly well, except for one problem. It fills it in a single column and overwrites this column when the next file is opened/selected.
Vision:
I would like that the VBA recognizes that the, in the code, D column is full and uses the E and at the selection of the third document the F column or either a selection in which I could tell, before the import of information begins, which column should be used.
I would like to thank you in advance for helping me.
Best regards,
Pezmerga
Code:
Sub test()
Dim wb As Workbook
Dim wb2 As Workbook
Dim ws As Worksheet
Dim vFile As Variant
Set wb = ActiveWorkbook
vFile = Application.GetOpenFilename("Excel-files,*.xl??", _
1, "Select One File To Open", , False)
If TypeName(vFile) = "Boolean" Then Exit Sub
Workbooks.Open vFile
Set wb2 = ActiveWorkbook
wb.Worksheets(“Sheet1”).Range("D13").Value = wb2.Worksheets(“Sheet1”).Range("E14").Value '1
wb.Worksheets(“Sheet1”).Range("D14").Value = wb2.Worksheets(“Sheet1”).Range("E15").Value '2
wb.Worksheets(“Sheet1”).Range("D16").Value = wb2.Worksheets(“Sheet1”).Range("E18").Value '3
wb.Worksheets(“Sheet1”).Range("D17").Value = wb2.Worksheets(“Sheet1”).Range("E19").Value '4
wb.Worksheets(“Sheet1”).Range("D18").Value = wb2.Worksheets(“Sheet1”).Range("E20").Value '5
wb.Worksheets(“Sheet1”).Range("D22").Value = wb2.Worksheets(“Sheet1”).Range("E25").Value '6
wb.Worksheets(“Sheet1”).Range("D23").Value = wb2.Worksheets(“Sheet1”).Range("E26").Value '7
wb.Worksheets(“Sheet1”).Range("D27").Value = wb2.Worksheets(“Sheet1”).Range("E31").Value '8
wb.Worksheets(“Sheet1”).Range("D28").Value = wb2.Worksheets(“Sheet1”).Range("E32").Value '9
wb.Worksheets(“Sheet1”).Range("D29").Value = wb2.Worksheets(“Sheet1”).Range("E33").Value '10
wb.Worksheets(“Sheet1”).Range("D37").Value = wb2.Worksheets(“Sheet1”).Range("E37").Value '11
wb.Worksheets(“Sheet1”).Range("D38").Value = wb2.Worksheets(“Sheet1”).Range("E38").Value '12
wb.Worksheets(“Sheet1”).Range("D39").Value = wb2.Worksheets(“Sheet1”).Range("E39").Value '13
wb.Worksheets(“Sheet1”).Range("D47").Value = wb2.Worksheets(“Sheet1”).Range("E43").Value '14
wb.Worksheets(“Sheet1”).Range("D53").Value = wb2.Worksheets(“Sheet1”).Range("G45").Value '15
wb.Worksheets(“Sheet1”).Range("D58").Value = wb2.Worksheets(“Sheet1”).Range("G46").Value '16
wb.Worksheets(“Sheet1”).Range("D63").Value = wb2.Worksheets(“Sheet1”).Range("G47").Value '17
wb.Worksheets(“Sheet1”).Range("D68").Value = wb2.Worksheets(“Sheet1”).Range("G49").Value '18
wb.Worksheets(“Sheet1”).Range("D73").Value = wb2.Worksheets(“Sheet1”).Range("G50").Value '19
wb.Worksheets(“Sheet1”).Range("D78").Value = wb2.Worksheets(“Sheet1”).Range("G51").Value '20
wb.Worksheets(“Sheet1”).Range("D83").Value = wb2.Worksheets(“Sheet1”).Range("G53").Value '21
wb.Worksheets(“Sheet1”).Range("D117").Value = wb2.Worksheets(“Sheet1”).Range("E70").Value '22
wb.Worksheets(“Sheet1”).Range("D118").Value = wb2.Worksheets(“Sheet1”).Range("E71").Value '23
wb.Worksheets(“Sheet1”).Range("D125").Value = wb2.Worksheets(“Sheet1”).Range("E73").Value '24
wb.Worksheets(“Sheet1”).Range("D131").Value = wb2.Worksheets(“Sheet1”).Range("E74").Value '25
wb.Worksheets(“Sheet1”).Range("D132").Value = wb2.Worksheets(“Sheet1”).Range("E75").Value '26
wb.Worksheets(“Sheet1”).Range("D151").Value = wb2.Worksheets(“Sheet1”).Range("E82").Value '27
wb2.Close savechanges:=False
End Sub