VBA Code that Enters a Note in a Column when another Column has some form of value/data in it

bmkelly

Board Regular
Joined
Mar 26, 2020
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am in the middle of creating a bunch of macros and one thing I am stuck on is, how do I go about adding "Under Contract" in the Analyst Notes Column (T) when there is some form of data in the Vendor Contract Column (AD)? Not all thedata in Vendor Contract will be the same, its either blank or it has some contract code in the column and I need the ones that have a contract code to then enter the note in the Analyst Notes column.

Analyst NotesSite Manager NotesCorrectionsSVCModalityEQStatusSub StatusInstalledDateOwnershipWarrantyCodeVendorContractVendorContractEnd
$ 66,629.11BIOMEDActiveOwned
2/15/2005​
TVC010919
11/30/2022​

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
How about
VBA Code:
Sub bmkelly()
   With Range("AD2", Range("AD" & Rows.Count).End(xlUp))
      .SpecialCells(xlConstants).Offset(, -10).Value = "Under Contract"
   End With
End Sub
 
Upvote 0
How about
VBA Code:
Sub bmkelly()
   With Range("AD2", Range("AD" & Rows.Count).End(xlUp))
      .SpecialCells(xlConstants).Offset(, -10).Value = "Under Contract"
   End With
End Sub
Thats perfect!....Is it too complicated/complex to have it read by column headers instead of columns. I only ask, because multiple users will be using this code in different spreadsheets and if they add columns then the code won't work accurately, correct?

Thank you again Fluff!
 
Upvote 0
How about
VBA Code:
Sub bmkelly()
   Dim Vcol As Range, Acol As Range
   
   Set Vcol = Range("1:1").Find("VendorContract", , , xlWhole, , , False, , False)
   Set Acol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
   
   If Vcol Is Nothing Or Acol Is Nothing Then
      MsgBox "header is missing"
      Exit Sub
   End If
   With Range(Vcol, Cells(Rows.Count, Vcol.Column).End(xlUp))
      .SpecialCells(xlConstants).Offset(, Acol.Column - Vcol.Column).Value = "Under Contract"
   End With
End Sub
 
Upvote 0
How about
VBA Code:
Sub bmkelly()
   Dim Vcol As Range, Acol As Range
  
   Set Vcol = Range("1:1").Find("VendorContract", , , xlWhole, , , False, , False)
   Set Acol = Range("1:1").Find("Analyst Notes", , , xlWhole, , , False, , False)
  
   If Vcol Is Nothing Or Acol Is Nothing Then
      MsgBox "header is missing"
      Exit Sub
   End If
   With Range(Vcol, Cells(Rows.Count, Vcol.Column).End(xlUp))
      .SpecialCells(xlConstants).Offset(, Acol.Column - Vcol.Column).Value = "Under Contract"
   End With
End Sub
That works! Thanks again Fluff! You have definitely came to save the day here numerous times! I have a few more I will probably be posting in new threads but once I Have two more codes done you wont have to be bothered by all my questions haha!

Thank you!
 
Upvote 0
Glad to help & thanks for the feedback.
I just noticed something actually.....When running that code it changes my Analyst Notes Column Header to "Under Contract" once I finish stepping thru this step-

" SpecialCells(xlConstants).Offset(, ACol.Column - VCol.Column).Value = "Review - Contract" "
 
Upvote 0
In that case use
VBA Code:
With Range(Vcol.Offset(1), Cells(Rows.Count, Vcol.Column).End(xlUp))
 
Upvote 0
Solution
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,044
Members
449,063
Latest member
ak94

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top