Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Combobox ctrl on worksheet

Hi,

I have several comboboxes(from toolbox, not forms) on a worksheet, and I'm
having trouble with the following code. I get the "object doesn't support
this method" error. Where am I going wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng

p = 4
For Each ctrl In Worksheets("LessonForm").Controls
If TypeOf ctrl Is MSForms.ComboBox Then
Rng.Offset(0, p).Value = ctrl.Value
p = p + 1
End If
Next ctrl

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Combobox ctrl on worksheet

Hi Robbyn,

Try something like:
'========================
Sub TestIt()
Dim sh As Worksheet
Dim rng As Range
Dim OLEObj As OLEObject
Dim p As Long

With Worksheets("Database")
Set rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

Set sh = Worksheets("LessonForm")

p = 4

For Each OLEObj In sh.OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
rng.Offset(0, p).Value = OLEObj.Object.Value
p = p + 1
End If
Next OLEObj

End Sub
'<<========================

---
Regards,
Norman



"Robbyn" wrote in message
...
Hi,

I have several comboboxes(from toolbox, not forms) on a worksheet, and
I'm
having trouble with the following code. I get the "object doesn't support
this method" error. Where am I going wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng

p = 4
For Each ctrl In Worksheets("LessonForm").Controls
If TypeOf ctrl Is MSForms.ComboBox Then
Rng.Offset(0, p).Value = ctrl.Value
p = p + 1
End If
Next ctrl



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Combobox ctrl on worksheet

Worked like a charm! Thanks sooo much Norman!

"Norman Jones" wrote:

Hi Robbyn,

Try something like:
'========================
Sub TestIt()
Dim sh As Worksheet
Dim rng As Range
Dim OLEObj As OLEObject
Dim p As Long

With Worksheets("Database")
Set rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

Set sh = Worksheets("LessonForm")

p = 4

For Each OLEObj In sh.OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
rng.Offset(0, p).Value = OLEObj.Object.Value
p = p + 1
End If
Next OLEObj

End Sub
'<<========================

---
Regards,
Norman



"Robbyn" wrote in message
...
Hi,

I have several comboboxes(from toolbox, not forms) on a worksheet, and
I'm
having trouble with the following code. I get the "object doesn't support
this method" error. Where am I going wrong?

With Worksheets("Database")
Set Rng = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
With Rng

p = 4
For Each ctrl In Worksheets("LessonForm").Controls
If TypeOf ctrl Is MSForms.ComboBox Then
Rng.Offset(0, p).Value = ctrl.Value
p = p + 1
End If
Next ctrl




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
Excel 2007: Ctrl+PgUp or Ctrl+PgDn with Protected Sheets DrDave Excel Discussion (Misc queries) 1 July 28th 08 04:12 AM
CTRL Find is preventing me from navigating around my worksheet gillywilly55 Excel Discussion (Misc queries) 1 April 3rd 06 12:36 PM
Switch between protected worksheet by CTRL-PgDown Dusan Grubor Excel Worksheet Functions 5 April 10th 05 07:55 PM
ctrl A to copy whole worksheet starwil Excel Programming 2 May 19th 04 05:10 PM
Copying Worksheet triggers Click event of combobox on another worksheet Robert[_20_] Excel Programming 0 January 23rd 04 07:40 PM


All times are GMT +1. The time now is 02:19 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"