Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default problem w/ size of combobox & using TopLeftCell


(code below mostly borrowed from "Excel 2002 VBA" pub. by WROX)

Using the code below, if the user is on Sheet1 and double-clicks on a
cell in column Q (e.g. Q5), a combobox is inserted at Q5 and populated
(see code). When the user chooses from the combobox, his choice is put
into Q5 (using

TopLeftCell.Value = .List(.ListIndex)

after which the combobox is deleted.

When I first tested (e.g in cell Q5), I went crazy because the value
was somehow inserted in cell P4. (One row up and one column left.) Note
that Excel's zoom setting was at 75%. When I changed the zoom to 100%,
the code ran fine and the selected value was inserted (correctly) in
Q5.

I used a message box to check the address of TopLeftCell and, in fact
the value of that property (for the same combobox) changed when I
changed the zoom setting.

Any suggestions on how I can fix this? I thought my code for the size
of the combobox fit the control to the size of the cell, but must be
more to this.

Thanks in advance.
Bill


<code below in module for Sheet1

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Not Intersect(Target, Columns("Q")) Is Nothing Then
Call AddDropDown(Target)
Cancel = True
End If
End Sub

< code below in Module 1

Sub AddDropDown(Target As Range)
Dim ddBox As DropDown
Dim vaProducts As Variant
Dim i As Integer

vaProducts = Array( _
"No Schedule At All", _
"Different results with different criteria", _
"Schedules wrong (times, train#, etc.)", _
"Schedules missing", _
"Schedules from useless stations", _
"Have to choose stations", _
"Ticket not matching", _
"Ticket missing", _
"Other")
With Target
Set ddBox = Sheet1.DropDowns.Add(.Left, .Top, .Width, .Height)
End With
With ddBox
OnAction = "EnterProdInfo"
For i = LBound(vaProducts) To UBound(vaProducts)
AddItem vaProducts(i)
Next i
End With
End Sub

Private Sub EnterProdInfo()
With Sheet1.DropDowns(Application.Caller)
TopLeftCell.Value = .List(.ListIndex)
Delete
End With
End Sub


--
Bill_excelforum
------------------------------------------------------------------------
Bill_excelforum's Profile: http://www.excelforum.com/member.php...o&userid=32280
View this thread: http://www.excelforum.com/showthread...hreadid=520327

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
combobox text size CraigSA Excel Discussion (Misc queries) 0 May 18th 06 02:46 PM
range variable won't assign (chartobject.topleftcell property) Matthew Dodds Excel Programming 2 November 16th 05 02:25 PM
TopLeftCell.Address for buttons from forms toolbar Andy Excel Programming 3 November 11th 05 05:12 AM
Combobox to fit the size of a cell Lotus123 Excel Worksheet Functions 0 November 7th 05 05:07 AM
ComboBox move and size Doug Glancy Excel Programming 0 May 26th 04 12:07 AM


All times are GMT +1. The time now is 07:32 AM.

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"