Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default userform variables

Hi there hope some one can point me in the right direction. i dont seem to
be able to see the wood for the trees.

I have a userform that I use to collect input from users, i also populate it
from a data source. i use a list of field names that relate to both the range
names on a worksheet and with a prefix of "UF" to the userform both in terms
of controls and variables. I loop through the list and with the controls i
use Range(field) = .Controls(form).Value. how do i deal with the variables
"AdmissionDate", "DateTimeStamp" which in the code for the userform are
prefixed by "UF"
ie how do i pass the values to the relevant range

please see following code

Public Sub datatransfer()
With Workbooks("Cram")
.Activate
With Worksheets("info")
'cram is userform
With Cram
For Each field In Range("datalabels")
form = "UF" & field
Select Case field
Case "AdmissionDate", "DateTimeStamp"

'What do i use here?

Case Else
Range(field) = .Controls(form).Value
End Select
Next
End With

End With
End With
End Sub

many thanks in anticipation

--
Message posted via http://www.officekb.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default userform variables

If you are trying to pass the variable "form" to a range on the worksheet,
then assume the range is cell A1:

ActiveSheet.Range("A1") = form 'substitute actual sheet and range

This would execute when the case is "Admission Date" or "Time Stamp"

"pjbur2005 via OfficeKB.com" wrote:

Hi there hope some one can point me in the right direction. i dont seem to
be able to see the wood for the trees.

I have a userform that I use to collect input from users, i also populate it
from a data source. i use a list of field names that relate to both the range
names on a worksheet and with a prefix of "UF" to the userform both in terms
of controls and variables. I loop through the list and with the controls i
use Range(field) = .Controls(form).Value. how do i deal with the variables
"AdmissionDate", "DateTimeStamp" which in the code for the userform are
prefixed by "UF"
ie how do i pass the values to the relevant range

please see following code

Public Sub datatransfer()
With Workbooks("Cram")
.Activate
With Worksheets("info")
'cram is userform
With Cram
For Each field In Range("datalabels")
form = "UF" & field
Select Case field
Case "AdmissionDate", "DateTimeStamp"

'What do i use here?

Case Else
Range(field) = .Controls(form).Value
End Select
Next
End With

End With
End With
End Sub

many thanks in anticipation

--
Message posted via http://www.officekb.com


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default userform variables

thanks for your input,

form contains the variable name "UFAdmissiondate" i want (say) range "A1" to
contain the value of "UFAdmissionDate"

JLGWhiz wrote:
If you are trying to pass the variable "form" to a range on the worksheet,
then assume the range is cell A1:

ActiveSheet.Range("A1") = form 'substitute actual sheet and range

This would execute when the case is "Admission Date" or "Time Stamp"

Hi there hope some one can point me in the right direction. i dont seem to
be able to see the wood for the trees.

[quoted text clipped - 34 lines]

many thanks in anticipation


--
Message posted via http://www.officekb.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default userform variables

You probably want to change :
From: form = "UF" & field
To: form = "UF" & field.Value

You should also Dim field As Range at the beginning of your macro.
Then, the syntax for the code that I gave you should work.

Let's say that the worksheet cell C5 is in Range("Data Labels") and is named
Admission Date with a value of "357". When the For...Next loop hits that
cell,
it triggers the Case and the value of "form" is now = UF357. You can make
any cell on any sheet equal form and UF357 will appear in that cell.

I am not sure that Admission Date is a cell name or range name but I assume
that it is one or the other by the way it is used. I do not see it in the
variables declarations because there were none posted.

"pjbur2005 via OfficeKB.com" wrote:

thanks for your input,

form contains the variable name "UFAdmissiondate" i want (say) range "A1" to
contain the value of "UFAdmissionDate"

JLGWhiz wrote:
If you are trying to pass the variable "form" to a range on the worksheet,
then assume the range is cell A1:

ActiveSheet.Range("A1") = form 'substitute actual sheet and range

This would execute when the case is "Admission Date" or "Time Stamp"

Hi there hope some one can point me in the right direction. i dont seem to
be able to see the wood for the trees.

[quoted text clipped - 34 lines]

many thanks in anticipation


--
Message posted via http://www.officekb.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default userform variables

Tried that and got error 424 object required........

Admissiondata is a value of a list called datalables
it is also a range callled admissiondate
it is also a variable within the code of userform "cram" when "UF" is a
prefifix (ie UFADmissionDate)
UFadmissionDate will contain a date derived on the userform using thre test
boxes for dd, mm and yy
these are put together for the date.

UFAdmissionDate is publically delacred as a date globally

JLGWhiz wrote:
You probably want to change :
From: form = "UF" & field
To: form = "UF" & field.Value

You should also Dim field As Range at the beginning of your macro.
Then, the syntax for the code that I gave you should work.

Let's say that the worksheet cell C5 is in Range("Data Labels") and is named
Admission Date with a value of "357". When the For...Next loop hits that
cell,
it triggers the Case and the value of "form" is now = UF357. You can make
any cell on any sheet equal form and UF357 will appear in that cell.

I am not sure that Admission Date is a cell name or range name but I assume
that it is one or the other by the way it is used. I do not see it in the
variables declarations because there were none posted.

thanks for your input,

[quoted text clipped - 13 lines]

many thanks in anticipation


--
Message posted via http://www.officekb.com

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
Userform and variables Jeff Excel Discussion (Misc queries) 1 May 24th 06 02:20 PM
How to get get variables to move from userform to main sub? Chet Excel Programming 1 May 10th 06 11:14 PM
Userform.Lable Variables Roger Excel Programming 6 October 9th 05 10:27 PM
Passing variables between Sub and Userform jose luis Excel Programming 8 July 22nd 05 05:20 PM
Passing variables from module to userform Chris Dunigan Excel Programming 4 November 26th 03 09:37 AM


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