S
sebastian1.schmidt
Hi,
I want to address cells dynamically, i.e. have a search function loop
through certain columns. When I write something like
------------------
Function source_range(ByVal sheetname As String, ByVal deliveryperiod
As String) As Range
Dim localloop As Integer
'ThisWorkbook.Worksheets(sheetname).Activate
For localloop = 1 To max_delivery_periods
With ThisWorkbook.Worksheets(sheetname)
If .Cells(delivery_period_row, localloop).Value =
deliveryperiod Then
source_range = .Range(.Cells(1,
localloop), .Cells(max_timeseries_length, localloop)) 'error here!
Exit Function
End If
End With
Next localloop
End Function
('delivery_period_row is a public const of type integer, as well as
max_timeseriws_length)
-----------------------
I get an error, "objectvariable not defined" (or similar). Why is
this, and how can I assign the range "more clever"?
Thanks for any help!
Seb.
I want to address cells dynamically, i.e. have a search function loop
through certain columns. When I write something like
------------------
Function source_range(ByVal sheetname As String, ByVal deliveryperiod
As String) As Range
Dim localloop As Integer
'ThisWorkbook.Worksheets(sheetname).Activate
For localloop = 1 To max_delivery_periods
With ThisWorkbook.Worksheets(sheetname)
If .Cells(delivery_period_row, localloop).Value =
deliveryperiod Then
source_range = .Range(.Cells(1,
localloop), .Cells(max_timeseries_length, localloop)) 'error here!
Exit Function
End If
End With
Next localloop
End Function
('delivery_period_row is a public const of type integer, as well as
max_timeseriws_length)
-----------------------
I get an error, "objectvariable not defined" (or similar). Why is
this, and how can I assign the range "more clever"?
Thanks for any help!
Seb.