Can I have a vba code that will do the following: Check the dates entered in B1:CC1 If…
- User
Can I have a vba code that will do the following: Check the dates entered in B1:CC1 If any of the dates match the dates entered in CX2:CX28 then where the match is found in B1:CC1 enter the value 'h' in the column from row 2 down to row 7
- Assistant
Certainly! Below is the VBA code that you can use to check the dates in the range
B1:CC1against the dates in the rangeCX2:CX28. If a match is found, it will enter the value 'h' in the corresponding column from row 2 down to row 7.You can add this code in the VBA editor (press
ALT + F11in Excel, insert a new module, and then copy and paste the code). - User
There are other values in the range B2:CC7. Instead of clearing the contents, can you change this to clear only 'h' values
- Assistant
- User
Apart from clearing the contents, I also want it to clear all Comments in the same range: ' Clear specific ranges (adjust as needed) Range("A3:B23, D3:E23, G3:H23, J3:K23, M3:N23, P3:Q23, S3:T23").ClearContents
- Assistant
- User
Sorry, the line of code I provided does not have anything to do with thw previous event, This is a new request. I want to know how to also clear the comments in the line of code I have just provided
- Assistant
Certainly! If you want to clear both the contents and comments in a specific range, you can use the following VBA code. This updated version will clear the contents and comments for the specified ranges:
A3:B23, D3:E23, G3:H23, J3:K23, M3:N23, P3:Q23, S3:T23.Here’s how you can implement this:
- User
Can you apply the Comments delete to this code: Sub ArchiveLeaveDates() Me.Unprotect Password:="edit" Dim userRange As Range Dim headerRange As Range Dim lastRow As Long Dim pasteCell As Range ' Prompt user to select a range Set userRange = Application.InputBox("SELECT YOUR ROWS", Type:=8) ' Check for canceled input If userRange Is Nothing Then Exit Sub ' Find last row in column B (excluding headers) lastRow = Cells(Rows.Count, "B").End(xlUp).Row ' Find next empty row after row 24 Set pasteCell = Cells(lastRow + 1, 1) Do While Not IsEmpty(pasteCell.Offset(0, 20)) ' Check if next row is empty up to column U Set pasteCell = pasteCell.Offset(1, 0) ' Move down until empty row found Loop ' Copy values only from user selection to the found empty row pasteCell.Resize(userRange.Rows.Count, userRange.Columns.Count).Value = userRange.Value
code - Assistant