![]() |
Misunderstanding of Objects please clarify
I have some controls in an userfor, their contents (value/text) are the
result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. |
Misunderstanding of Objects please clarify
hi,
Range(X) should be a range object not a number of columns set X = Range("A1") or Set X = range("A1:B10") -- Regards, Halim "LuisE" wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. |
Misunderstanding of Objects please clarify
I thin it is, this is the code
Set ws = Sheets("mysheet") Set UnitList = ws.Range("a:a") With UnitList Set rFound = .Find(What:=UnitNo, _ After:=Range("A1"), LookIn:=xlValues, _ Lookat:=xlWhole, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False) If Not rFound Is Nothing Then X = rFound.Address the rest of the code "Halim" wrote: hi, Range(X) should be a range object not a number of columns set X = Range("A1") or Set X = range("A1:B10") -- Regards, Halim "LuisE" wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. |
Misunderstanding of Objects please clarify
Take a look at VBA's help for .text. You'll see that it's a readonly property
for a range object. Try: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption ps. Instead of using syntax like: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption you could use: rFound.Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption And if this code is behind the userform, you may find it safer to use the key word Me (the object that owns the code--in this case the userform itself). rFound.Offset(0, 6).Value = me.CheckBox1.Caption You won't have to worry about renaming the userform--or copy|pasting the code to a new userform. LuisE wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. -- Dave Peterson |
Misunderstanding of Objects please clarify
I tried and it is still giving me an error.
Is t because The code for for rFound, X and ws is in another Module. "Dave Peterson" wrote: Take a look at VBA's help for .text. You'll see that it's a readonly property for a range object. Try: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption ps. Instead of using syntax like: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption you could use: rFound.Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption And if this code is behind the userform, you may find it safer to use the key word Me (the object that owns the code--in this case the userform itself). rFound.Offset(0, 6).Value = me.CheckBox1.Caption You won't have to worry about renaming the userform--or copy|pasting the code to a new userform. LuisE wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. -- Dave Peterson |
Misunderstanding of Objects please clarify
I change the .text to .value and worked. Thanks a lot Dave.
"Dave Peterson" wrote: Take a look at VBA's help for .text. You'll see that it's a readonly property for a range object. Try: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption ps. Instead of using syntax like: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption you could use: rFound.Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption And if this code is behind the userform, you may find it safer to use the key word Me (the object that owns the code--in this case the userform itself). rFound.Offset(0, 6).Value = me.CheckBox1.Caption You won't have to worry about renaming the userform--or copy|pasting the code to a new userform. LuisE wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. -- Dave Peterson |
Misunderstanding of Objects please clarify
I think it's time to post your current code. And indicate what line causes the
trouble. LuisE wrote: I tried and it is still giving me an error. Is t because The code for for rFound, X and ws is in another Module. "Dave Peterson" wrote: Take a look at VBA's help for .text. You'll see that it's a readonly property for a range object. Try: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption ps. Instead of using syntax like: ws.Range(X).Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption you could use: rFound.Offset(0, 6).Value = FrmMove_In.CheckBox1.Caption And if this code is behind the userform, you may find it safer to use the key word Me (the object that owns the code--in this case the userform itself). rFound.Offset(0, 6).Value = me.CheckBox1.Caption You won't have to worry about renaming the userform--or copy|pasting the code to a new userform. LuisE wrote: I have some controls in an userfor, their contents (value/text) are the result of a look up in a sheet. I want to update/change those values and paste them back in the sheet in the same cells they come from. When I try to do it I get the "Object Requiered" error. Here is an example ws.Range(X).Offset(0, 6).Text = FrmMove_In.CheckBox1.Caption ws= is the sheet where I'm retrieving the record from x=is the column where the record is. Help is greatly appreciated. -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 05:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com