asked on
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 1 And Target.Value <> "" Then
retval = MsgBox("Record " & Target.Value & " as paid?", vbYesNo, "Pay Master")
If retval = vbNo Then
'do nothing
Else
Range("Blue:Green").EntireColumn.Hidden = True
Sheets("Paid").Rows("2:2").Insert Shift:=xlDown
With Rows(ActiveCell.Row).SpecialCells(xlCellTypeConstants, 23)
.SpecialCells(xlCellTypeVisible).Copy Destination:=Sheets("Paid").Range("A2")
End With
End If
End If
Application.EnableEvents = True
End Sub
Sub Paid()
Dim ws As Worksheet
Dim lngCol As Long
Dim cel As Range
Dim rng As Range
Dim LastColumn As Long
Set ws = Worksheets("Main")
With ws
Worksheets("Paid").Rows("2:2").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
LastColumn = .Cells.Find("*", SearchOrder:=xlByColumns, LookIn:=xlValues, SearchDirection:=xlPrevious).Column
.Range("Blue" & ":" & "Green").EntireColumn.Hidden = True
Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, LastColumn)).Select
Set rng = Selection.Cells.SpecialCells(xlCellTypeVisible)
For Each cel In rng
lngCol = lngCol + 1
Worksheets("Paid").Cells(2, lngCol) = cel
Next
End With
End Sub
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
Open in new window