J
jacqui
In the following code (full code below), how do I make the
first visible row from the Autofilter selection my
variable in the line which says
Cells(cell.Row, j).Value = Cells(cell.Row, 6).Value
At the moment VBA is inserting the value in the correct
column but inserting it in the row opposite the value. I
need an anchor to represent the first visible row for each
autofilter repetition. Tom if you are still on-line can
you possibly help urgently with this one please.
Many thanks
Jacqui
Full code is
Dim i As Long, j As Long, k As Long, n As Long
Dim rng As Range, cell As Range
Dim sChar As String
n = 2
Worksheets("Table4").Select
For i = 1 To 256
If Application.CountA(Columns(i)) = 0 Then
j = i - 1
Exit For
End If
Next
For i = 1 To 8
j = j + 1
n = 2
Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End
(xlUp))
For Each cell In rng
If cell.EntireRow.Hidden = False Then
sChar = Left(cell, 1)
If IsNumeric(sChar) Then
k = CLng(sChar)
If k = i Then
Cells(cell.Row, j).Value = Cells(cell.Row, 6).Value
n = n + 1
End If
End If
End If
Next
Next
End Sub
first visible row from the Autofilter selection my
variable in the line which says
Cells(cell.Row, j).Value = Cells(cell.Row, 6).Value
At the moment VBA is inserting the value in the correct
column but inserting it in the row opposite the value. I
need an anchor to represent the first visible row for each
autofilter repetition. Tom if you are still on-line can
you possibly help urgently with this one please.
Many thanks
Jacqui
Full code is
Dim i As Long, j As Long, k As Long, n As Long
Dim rng As Range, cell As Range
Dim sChar As String
n = 2
Worksheets("Table4").Select
For i = 1 To 256
If Application.CountA(Columns(i)) = 0 Then
j = i - 1
Exit For
End If
Next
For i = 1 To 8
j = j + 1
n = 2
Set rng = Range(Cells(2, 1), Cells(Rows.Count, 1).End
(xlUp))
For Each cell In rng
If cell.EntireRow.Hidden = False Then
sChar = Left(cell, 1)
If IsNumeric(sChar) Then
k = CLng(sChar)
If k = i Then
Cells(cell.Row, j).Value = Cells(cell.Row, 6).Value
n = n + 1
End If
End If
End If
Next
Next
End Sub