ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   variable problem error 424 (https://www.excelbanter.com/excel-programming/416426-variable-problem-error-424-a.html)

pjbur2005 via OfficeKB.com

variable problem error 424
 
Not sure if i am getting this over very well but here goes

I have a list called "Datalables"

in this list i have a value ""AdmissionDate"

I have a range called "AdmissionDate"

I have a userform With all controls prefixed with "UF"

in the userform i use a variable called "UFAdmissionDate"

i loop through the "Datalabels" list if = "AdmissionDate" i want the range
"AdmissionDate" to be given the Value Of "UFAdmissionDate"

if value is not "AdmissionDate" then i get the value of the control called
"UF" & the list value.
M when i run this i get 424 error object required can someone see what i am
doing wrong

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"
' following line produces object required error 424
Worksheets("info").Range(field) = form.
Value
Case Else
Range(field) = .Controls(form).Value
End Select
Next
End With

End With
End With
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1


Jim Thomlinson

variable problem error 424
 
You have
form.value
but form is a variable and not an object so it does not have a value
property...

Try
Worksheets("info").Range(field) = form

--
HTH...

Jim Thomlinson


"pjbur2005 via OfficeKB.com" wrote:

Not sure if i am getting this over very well but here goes

I have a list called "Datalables"

in this list i have a value ""AdmissionDate"

I have a range called "AdmissionDate"

I have a userform With all controls prefixed with "UF"

in the userform i use a variable called "UFAdmissionDate"

i loop through the "Datalabels" list if = "AdmissionDate" i want the range
"AdmissionDate" to be given the Value Of "UFAdmissionDate"

if value is not "AdmissionDate" then i get the value of the control called
"UF" & the list value.
M when i run this i get 424 error object required can someone see what i am
doing wrong

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"
' following line produces object required error 424
Worksheets("info").Range(field) = form.
Value
Case Else
Range(field) = .Controls(form).Value
End Select
Next
End With

End With
End With
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200809/1




All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com