Mental Block! help required.
Good day all,
I have a spredsheet which makes reference to "My table" in the code below
Sub NewSheetData()
Dim rCell As Range
Dim Rng As Range
Dim MySh As String
Dim lw As Integer
Dim lr As Integer
Dim sh As Worksheet
Application.ScreenUpdating = False
Set sh = Sheets("All Vehicles")
sh.Activate
Set Rng = Range("A1:A" & Range("A65536").End(xlUp).Row)
Rng.Select
For Each rCell In Range("MyTable")
On Error Resume Next
MySh = rCell.Value
With Rng
.AutoFilter , Field:=1, Criteria1:=rCell.Value
lw = Range("A" & Rows.Count).End(xlUp).Row
lr = Worksheets(MySh).Range("A" & Rows.Count).End(xlUp).Row + 1
Range(Cells(2, 1), Cells(lw, 6)).Copy
Worksheets(MySh).Range("A" & lr).PasteSpecial xlPasteValues
.AutoFilter
End With
On Error GoTo 0
Next rCell
Teh thing is the rCell keeps taking the value from the B1 cell instead fo the A1 celland i cant see how rCell is being determined, can anyone help?
Thanks in advance
Colin
Attachment | Size |
---|---|
SpeedTable (Autosaved).xlsm | 772.55 KB |
check how the range MyTable
check how the range MyTable is defined..
insert=>name=> define... check the source of MyTable
Thanks but this is where i
Thanks but this is where i can't work out how to do it hence the "mental Block"
can you or anybody help?
Press CTRL+G Paste:
Press CTRL+G
Paste: MyTable
Press enter..
That will take you to the range
To redefine a name, press in sequence:
ALT i n d