Pasting selected text to clip board if checkboxs are true in VBA

markda2000

New Member
Joined
Mar 24, 2011
Messages
9
Hi,

I have a user form that will paste to clipboard the entries from the user form when a button in pressed. However it only shows the value of checkboxs being true or false which does not read easily (the purpose of the form is to paste into customer service advisors notes).

Is there anyway to have the copied item display text if the checkbox is checked and nothing if not. I guess I need to be using the IF function but I cannot get it to work.

Part of the code I have is below

Code:
Private Sub SaveNotesButton_Click()
Dim notestosendtoclipboard As String
Dim textobj As DataObject
Set textobj = New DataObject

notestosendtoclipboard =     "Paying by direct debit " & PayingByDD.Value 
textobj.SetText notestosendtoclipboard
textobj.PutInClipboard

End Sub

Sorry if this seems basic but I am very new at VBA
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Something like:
Code:
If Me.Checkbox1 then
' your code here
End If
 
Upvote 0
thanks for your reply Rorya, I seem to be having problems with the code that you gave me.
I think I may have over simplified the smaple code I posted though.

I have other lines of text to be pasted to the clipboard as well and three of these lines of text are to be dependant on the values of three checkbox's. when I put the If statement in the line of code where I want the Then text to be displayed I get a sytax compile error.

I am as you can tell very new to VBA and am struggling with the most basic tasks.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,741
Members
452,940
Latest member
rootytrip

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