Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello agian!
I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Craig,
Set iBox = Sheet1.textbox1 Try: Set ibox = Sheets("Sheet1").Shapes("textbox1") --- Regards, Norman "Craig" wrote in message news:ru9Ue.160385$Hk.63792@pd7tw1no... Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try
If varTest = 1 Then Set iBox = Sheets("Sheet1").TextBox1 etc Hope this helps Rowan Craig wrote: Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You may declare iBox as wrong Object type.
Try: Dim iBox as msforms.TextBox "Craig" wrote in message news:ru9Ue.160385$Hk.63792@pd7tw1no... Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Craig,
If the textboxes are from the control Toolbox, try something like: ..=========================== Sub TestIt() Dim VarTest As Long Dim iBox As OLEObject 'code to assign value to VarTest variable, e.g.: VarTest = 2 Set iBox = Sheets("Sheet1").OLEObjects("textbox" & VarTest) With iBox.Object .Text = "Test" .Enabled = False End With End Sub '<<=========================== --- Regards, Norman "Craig" wrote in message news:ru9Ue.160385$Hk.63792@pd7tw1no... Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi Craig! You can also just declare iBox as Object... Dim iBox as Object ... Set iBox = Sheet1.TextBox1 ... Craig Wrote: Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Crai -- T-®e ----------------------------------------------------------------------- T-®ex's Profile: http://www.excelforum.com/member.php...fo&userid=2657 View this thread: http://www.excelforum.com/showthread.php?threadid=46616 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes... Thanks, I did declare it as an Object.... then all worked fine! You'd
figure if it was a TextBox you'd declare it as a Textbox! Go Figure! Thanks Craig "T-®ex" wrote in message ... Hi Craig! You can also just declare iBox as Object... Dim iBox as Object .. Set iBox = Sheet1.TextBox1 .. Craig Wrote: Hello agian! I'm trying to set a textbox for use later in the code. Dim iBox as Textbox if varTest = 1 then Set iBox = Sheet1.textbox1 elseif varTest = 2 then Set iBox = Sheet1.textbox2 elseif varTest = 3 then Set iBox = Sheet1.textbox3 end if with iBox .text = "Test" .enabled=False etc... end with It errors during the Set iBox= line of codes, what am I doing wrong? Thanks Craig -- T-®ex ------------------------------------------------------------------------ T-®ex's Profile: http://www.excelforum.com/member.php...o&userid=26572 View this thread: http://www.excelforum.com/showthread...hreadid=466165 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I have had trouble with textbox text to worksheet | Excel Discussion (Misc queries) | |||
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys | Excel Programming | |||
Textbox Bug? Missing/delayed update of textbox filled via VBA | Excel Programming | |||
Textbox Bug? Missing/delayed update of textbox filled via VBA | Excel Programming | |||
Textbox trouble on a user form | Excel Programming |