How can I write a VBA code for the following; Print Columns A to K that are not hidden…
- User
How can I write a VBA code for the following; Print Columns A to K that are not hidden from Row 1 to last Row of column A that has a value
- Assistant
You can use the below VBA code to print Columns A to K that are not hidden from Row 1 to last Row of column A that has a value:
Sub PrintSelectedColumns() Dim LastRow As Long Dim iCol As Integer 'Determine the last row of data in column A LastRow = Cells(Rows.Count, "A").End(xlUp).Row 'Loop through each column from A to K For iCol = 1 To 11 'If the column is not hidden, then print it If Columns(iCol).Hidden = False Then Columns(iCol).Select Selection.PrintPreview End If Next iCol End SubNote: This code will print the selected columns in a print preview mode. If you want to print the columns directly, you can replace
Selection.PrintPreviewwithSelection.PrintOutin the code. - User
How can I add an AND condition ' AND A2 <>"" ' to this code; =IF(J2="","",IF(J2<(--"7:30 PM"),"OSS TO LOCK","SP LOCKS"))
- Assistant
You can add an AND condition 'AND A2 <>""' to the code in this way:
=IF(AND(A2<>"", J2<>"", J2<(--"7:30 PM")), "OSS TO LOCK", "SP LOCKS")This will check if both A2 and J2 are not blank and if J2 is less than the time 7:30 PM. If the conditions are met, it will return "OSS TO LOCK", otherwise "SP LOCKS".
- User
<> waht do these mean
- Assistant
In programming and Excel formulas,
<>stands for "not equal to". It is used to compare two values and checks if they are not equal to each other. For example,A <> Bmeans that A is not equal to B.In some programming languages and Excel formulas,
!=can also be used to mean "not equal to" instead of<>.