Hi everyone!!
basically all i need it to do now is do this for multiple sheets selected from a drop down, (listed on a separate page). each sheet is a date for e.g 07.02.13 and basically the below code works mite be a bit long winded but it works lol!!
now the additional thing that i need it to do is store each i instead of writing it direct to cell_count i need it to total each i and then write it, ive tried a few things but its been a while since i used vb for 1 plus im only a novice! lol any help would be much appreciated!! i hope someone can help
Cheers
Excel / VB community
Sub date_range1()
Application.ScreenUpdating = False
Sheets("overview").Select
Dim date_start As String
date_start = Range("H4")
Dim date_end As String
date_end = Range("H7")
Dim datesel1 As Range
Dim selection() As String
Dim blDimensioned As Boolean
Dim lngPosition As Long
Sheets("Sheet1").Select
blDimensioned = False
For Each datesel1 In Range("A:A")
If date_start = datesel1 Then
flag = True
End If
If flag = True Then
If datesel1 <> "" Then
If blDimensioned = True Then
ReDim Preserve selection(0 To UBound(selection) + 1) As String
Else
ReDim selection(0 To 0) As String
blDimensioned = True
End If
selection(UBound(selection)) = datesel1
End If
End If
If date_end = datesel1 Then
flag = False
End If
Next datesel1
'Write to cells
For Position = LBound(selection) To UBound(selection)
Sheets(selection(postion)).Select
Dim cell_count As Integer
Dim cell_id0 As String
Dim cell_id1 As String
Dim cell_id2 As String
Dim cell_id3 As String
Dim cell_id4 As String
cell_count = 11
For Each i In Range("I5:I24")
cell_id0 = "C" & cell_count
Sheets("overview").Select
Range(cell_id0) = i
Sheets(selection(Position)).Select
cell_count = cell_count + 1
Next i
cell_count = 11
For Each i In Range("J5:J24")
cell_id1 = "D" & cell_count
Sheets("overview").Select
Range(cell_id1) = i
Sheets(selection(Position)).Select
cell_count = cell_count + 1
Next i
cell_count = 11
For Each i In Range("K5:K24")
cell_id2 = "E" & cell_count
Sheets("overview").Select
Range(cell_id2) = i
Sheets(selection(Position)).Select
cell_count = cell_count + 1
Next i
cell_count = 11
For Each i In Range("L5:L24")
cell_id3 = "F" & cell_count
Sheets("overview").Select
Range(cell_id3) = i
Sheets(selection(Position)).Select
cell_count = cell_count + 1
Next i
cell_count = 11
For Each i In Range("M5:M24")
cell_id4 = "G" & cell_count
Sheets("overview").Select
Range(cell_id4) = i
Sheets(selection(Position)).Select
cell_count = cell_count + 1
Next i
Next Position
Erase selection
Application.ScreenUpdating = True
Sheets("overview").Activate
End Sub
Bookmarks