VBA: add comments to a cell with target being Combobox2.value and the comment being combobox1.value

JIB

New Member
Joined
Dec 24, 2019
Messages
12
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone, I'm fairly new at this and I cant seem to find a way around this after searching for answers on google and youtube.

As continuation to my previous thread, I am trying to add comments by referring to the value of a combobox. The target range will follow boundcolumn 2 of Combobox 2.
Combobox 2 range is =R2:S21
I've tried several ways and i'm still stuck so this is one of the entries I've had so far:

VBA Code:
ComboBox2.BoundColumn = 2
Dim cb2 As String
cb2 = ComboBox2.Text
Dim cb1 As String
cb1 = ComboBox1.Text

Worksheets("Sheet4").Range("cb2").Select
Worksheets("Sheet4").Range("cb2").AddComment
Worksheets("Sheet4").Range("cb2").Comment.Visible = False
Worksheets("Sheet4").Range("cb2").Comment.Text Text:="cb1" & Chr(10) & "" & Chr(10) & ""
VBA Code:

Appreciate any help I can get, Please and thank you
Ek2.png
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
VBA Code:
Private Sub CommandButton1_Click()

    Dim s As String
    Dim rng As String

    s = Me.ComboBox1
    rng = Me.ComboBox2.Value

    Range(rng).AddComment
    Range(rng).Comment.Visible = False
    Range(rng).Comment.Text Text:=s

End Sub
I set the boundcolumn in the properties for testing purposes.
1577283723790.png
 
  • Like
Reactions: JIB
Upvote 0
Thank you very much, just what I wanted :)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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