Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default Beginer to UserForms question on assigning properties to objects

Newbie to userforms question here.

Setting up a user UserForm for Data entry there are
32 TextBoxes named CAT1BOX, CAT2BOX, CAT3BOX,... CAT32BOX
28 Labels named CAT1, CAT2, CAT3, ... CAT28

I am trying to name and populate them dynamically using the For-Next
statement below, but am getting a RunTime error '91 "Object variable
or With block variable not set"

Private Sub UserForm_Initialize()
Dim MyField As Object, MyWork As Object

Me.Caption = "WorkFlow Tracking for " &
Sheets("Data").Range("B4").Value & _
" For " & Sheets("Data").Range("B3").Value

For i = 1 To 32
If i < 29 Then
MyField = "CAT" & i
MyField.Text = Sheets("data").Range("J17").Offset(-i + 1,
0).Value
MyWork = "CAT" & i & "BOX"
MyWork.Value = Sheets("data").Range("B12").Offset(0, i -
1).Value
Else
MyWork = "CAT" & i & "BOX"
MyWork.Value = Sheets("data").Range("B12").Offset(0, i -
1).Value
End If
Next
End Sub

I know I am not seeing something incrediblly stupid... If anyone knows
of an "Idiots guide to using UserForms in Excel" ...

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Beginer to UserForms question on assigning properties to objects

Just to loop differently (you can change it back!)

for i = 1 to 28
me.controls("cat" & i).caption _
= Sheets("data").Range("J17").Offset(-i + 1, 0).Value

me.controls("Cat" & i & "box").value _
MyWork.Value = Sheets("data").Range("B12").Offset(0, i - 1).Value
next i

for i = 29 to 32
me.controls("Cat" & i & "box").value _
MyWork.Value = Sheets("data").Range("B12").Offset(0, i - 1).Value
next i





wrote:

Newbie to userforms question here.

Setting up a user UserForm for Data entry there are
32 TextBoxes named CAT1BOX, CAT2BOX, CAT3BOX,... CAT32BOX
28 Labels named CAT1, CAT2, CAT3, ... CAT28

I am trying to name and populate them dynamically using the For-Next
statement below, but am getting a RunTime error '91 "Object variable
or With block variable not set"

Private Sub UserForm_Initialize()
Dim MyField As Object, MyWork As Object

Me.Caption = "WorkFlow Tracking for " &
Sheets("Data").Range("B4").Value & _
" For " & Sheets("Data").Range("B3").Value

For i = 1 To 32
If i < 29 Then
MyField = "CAT" & i
MyField.Text = Sheets("data").Range("J17").Offset(-i + 1,
0).Value
MyWork = "CAT" & i & "BOX"
MyWork.Value = Sheets("data").Range("B12").Offset(0, i -
1).Value
Else
MyWork = "CAT" & i & "BOX"
MyWork.Value = Sheets("data").Range("B12").Offset(0, i -
1).Value
End If
Next
End Sub

I know I am not seeing something incrediblly stupid... If anyone knows
of an "Idiots guide to using UserForms in Excel" ...


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 20
Default Beginer to UserForms question on assigning properties to objects

Thank you, that worked. Well it did as soon as I rememberd that down
is negative and changed the "-i +1" to "i-1" so that I wasn't trying
to read cells located about six inches above my computer... :)



On Jul 26, 7:41 am, Dave Peterson wrote:
Just to loop differently (you can change it back!)


Dave Peterson- Hide quoted text -

- Show quoted text -



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
Help with Userforms Panagiotis Marantos Excel Discussion (Misc queries) 2 July 25th 06 04:26 PM
I need some help with userforms T.c.Goosen1977 Charts and Charting in Excel 0 June 30th 06 09:29 AM
Question - How to group unique objects in Excel bradsaxon Excel Discussion (Misc queries) 1 April 14th 06 05:51 PM
Assigning VB to Grouped Objects Spinner Excel Discussion (Misc queries) 0 December 29th 05 08:32 PM
UserForms bennyob Excel Discussion (Misc queries) 4 November 7th 05 01:58 PM


All times are GMT +1. The time now is 01:32 PM.

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

About Us

"It's about Microsoft Excel"