How to add comment through VBA

KFrank

New Member
Joined
May 24, 2020
Messages
4
Office Version
  1. 2007
Platform
  1. Windows
Hi guys. I have a macro that asks a user to select a cell and then type in a number which is captured to the selected cell. I would like to know how to have the number that is typed to be entered into a comment. This is the code I have so far:

Sub AddCB()
Dim AddHours As String
sCell = Application.InputBox(Prompt:="Select a date", Type:=8)
AddHours = InputBox("How many Call Back hours?", "Add CB Hours", "Enter amount here")
ActiveCell.Value = "CB"
ActiveCell.Offset(0, -1).Value = AddHours
End Sub

I hope someone can help, thank you in advance.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Thank you for your reply. I have read the attached page yet being new to VBA, I am unsure what to add to my bit of code to use the input data in the comment box.
 
Upvote 0
Try
VBA Code:
ActiveCell.NoteText addHours

Although I do find it odd that the field title ("CB") is the cell's value while the field value is in the comments.
Typically, the value of a field is the cell's contents while the field's title is a column header. Storing values in comments causes problems when one tries to use those values downstream.
 
Upvote 0

Forum statistics

Threads
1,215,051
Messages
6,122,872
Members
449,097
Latest member
dbomb1414

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