JadeRogers
New Member
- Joined
- Jul 17, 2024
- Messages
- 2
- Office Version
- 365
Hi, needing some assistance on a code i currently have.
When i leave my code as follows it works as wanted but removes header rows. when changing to "A2:A" it hides all rows.
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
With ws.Range("A1:A" & lastRow)
.AutoFilter Field:=1, Criteria1:="0"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = ""
.AutoFilter
End With
Im assuming it may be placed incorrectly :| Full code as follows:
' SAPMonday Macro
'
'
Cells.Select
Selection.ColumnWidth = 8.43
Columns("A:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("U:U").Select
Selection.Copy
Columns("A:A").Select
ActiveSheet.Paste
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2", Range("B2").End(xlDown))
Range("B2", Range("B2").End(xlDown)).Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
With ws.Range("A2:A" & lastRow)
.AutoFilter Field:=1, Criteria1:="0"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = ""
.AutoFilter
End With
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
When i leave my code as follows it works as wanted but removes header rows. when changing to "A2:A" it hides all rows.
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
With ws.Range("A1:A" & lastRow)
.AutoFilter Field:=1, Criteria1:="0"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = ""
.AutoFilter
End With
Im assuming it may be placed incorrectly :| Full code as follows:
' SAPMonday Macro
'
'
Cells.Select
Selection.ColumnWidth = 8.43
Columns("A:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("U:U").Select
Selection.Copy
Columns("A:A").Select
ActiveSheet.Paste
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=VALUE(RC[-1])"
Range("B2").Select
Selection.AutoFill Destination:=Range("B2", Range("B2").End(xlDown))
Range("B2", Range("B2").End(xlDown)).Select
Selection.Copy
Range("A2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
With ws.Range("A2:A" & lastRow)
.AutoFilter Field:=1, Criteria1:="0"
.Offset(1, 0).SpecialCells(xlCellTypeVisible).Value = ""
.AutoFilter
End With
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 255
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub