Hi,
does anybody know how to use the variable "Cel" in the PrivatSub Code???? I tried it with declaring "Cel" as Public Variable but it does not work.
Option Explicit
Sub Makro1()
Dim fpath As String
Dim Cel As Range
fpath = Sheets("Sheets1").Range("E1").Value
For Each Cel In Range("B3:S3")
If InStr(Cel, ".csv") Then WorkOnCSV fpath, Cel
Next Cel
End Sub
Private Sub WorkOnCSV(fpath As String, fnameCell As Range)
Dim tool As Workbook
Dim daten As Workbook
Dim col As Variant
Set tool = ThisWorkbook
Set daten = Workbooks.Open(fpath & fnameCell, ReadOnly:=True)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
daten.Activate
Let col = Application.Match("Price(12y)", Rows(1), 0)
If Not IsError(col) Then
Cells(2, col).Resize(61).Copy _
Destination:=tool.Worksheets("Sheets2").Range("L11")
Else: MsgBox ("Name not Found")
End If
tool.Activate
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
tool.Worksheets("Sheets2").Range("N12").End(xlDown).Copy _
Destination:=tool.Worksheets("Sheets1").Range("Cel").Offset(1, 0) <---- here is the error
daten.Close savechanges:=False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
does anybody know how to use the variable "Cel" in the PrivatSub Code???? I tried it with declaring "Cel" as Public Variable but it does not work.
Option Explicit
Sub Makro1()
Dim fpath As String
Dim Cel As Range
fpath = Sheets("Sheets1").Range("E1").Value
For Each Cel In Range("B3:S3")
If InStr(Cel, ".csv") Then WorkOnCSV fpath, Cel
Next Cel
End Sub
Private Sub WorkOnCSV(fpath As String, fnameCell As Range)
Dim tool As Workbook
Dim daten As Workbook
Dim col As Variant
Set tool = ThisWorkbook
Set daten = Workbooks.Open(fpath & fnameCell, ReadOnly:=True)
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
daten.Activate
Let col = Application.Match("Price(12y)", Rows(1), 0)
If Not IsError(col) Then
Cells(2, col).Resize(61).Copy _
Destination:=tool.Worksheets("Sheets2").Range("L11")
Else: MsgBox ("Name not Found")
End If
tool.Activate
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
tool.Worksheets("Sheets2").Range("N12").End(xlDown).Copy _
Destination:=tool.Worksheets("Sheets1").Range("Cel").Offset(1, 0) <---- here is the error
daten.Close savechanges:=False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub