Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how to reference worksheet as control source with space in name

My worksheet was called "Audit Checklist" and in VBA I reffered to it as :
LearnerCount = Worksheets("Audit Checklist").Range("d2").Value

and all works fine.

I have created a userform now and wanted to amend some cells from selected
data so:

Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "Audit Checklist!c4"
Me.CBStaffName.ControlSource = "Audit Checklist!P4"
End Sub

this caused ar error for the control source becuase it wanted:
"AuditChecklist!P4"

how do I reference without renaming the worksheet?

regards
peter


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how to reference worksheet as control source with space in name

Peter,

It's the embedded spaces,

try
Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "'Audit Checklist!'c4"
Me.CBStaffName.ControlSource = "'Audit Checklist'!P4"
End Sub


--

HTH

RP

"Peter Bailey" wrote in message
...
My worksheet was called "Audit Checklist" and in VBA I reffered to it as :
LearnerCount = Worksheets("Audit Checklist").Range("d2").Value

and all works fine.

I have created a userform now and wanted to amend some cells from selected
data so:

Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "Audit Checklist!c4"
Me.CBStaffName.ControlSource = "Audit Checklist!P4"
End Sub

this caused ar error for the control source becuase it wanted:
"AuditChecklist!P4"

how do I reference without renaming the worksheet?

regards
peter




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default how to reference worksheet as control source with space in name

at last such a small thing!

regards
Peter
"Bob Phillips" wrote in message
...
Peter,

It's the embedded spaces,

try
Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "'Audit Checklist!'c4"
Me.CBStaffName.ControlSource = "'Audit Checklist'!P4"
End Sub


--

HTH

RP

"Peter Bailey" wrote in message
...
My worksheet was called "Audit Checklist" and in VBA I reffered to it as
:
LearnerCount = Worksheets("Audit Checklist").Range("d2").Value

and all works fine.

I have created a userform now and wanted to amend some cells from
selected
data so:

Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "Audit Checklist!c4"
Me.CBStaffName.ControlSource = "Audit Checklist!P4"
End Sub

this caused ar error for the control source becuase it wanted:
"AuditChecklist!P4"

how do I reference without renaming the worksheet?

regards
peter






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default how to reference worksheet as control source with space in name

I like this so I don't have to worry:

Me.CBCentre.ControlSource _
= Worksheets("Audit Checklist").Range("c4").address(external:=true)



Peter Bailey wrote:

My worksheet was called "Audit Checklist" and in VBA I reffered to it as :
LearnerCount = Worksheets("Audit Checklist").Range("d2").Value

and all works fine.

I have created a userform now and wanted to amend some cells from selected
data so:

Private Sub UserForm_Initialize()
Me.CBCentre.ControlSource = "Audit Checklist!c4"
Me.CBStaffName.ControlSource = "Audit Checklist!P4"
End Sub

this caused ar error for the control source becuase it wanted:
"AuditChecklist!P4"

how do I reference without renaming the worksheet?

regards
peter


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax for control source in combo box control dhstein Excel Discussion (Misc queries) 1 August 12th 09 05:38 PM
How can I control space between lines in a text? Elfinka Excel Discussion (Misc queries) 2 March 16th 09 04:49 PM
Excel row space control. 1LMR Excel Discussion (Misc queries) 1 November 8th 08 11:12 PM
Control Source Dave D[_3_] Excel Programming 1 April 28th 04 07:20 PM
Control Source Steven Taylor[_2_] Excel Programming 0 July 16th 03 04:01 PM


All times are GMT +1. The time now is 08:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"