Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
general misunderstanding | Excel Discussion (Misc queries) | |||
Misunderstanding isblank | Excel Worksheet Functions | |||
Range Object Misunderstanding | Excel Programming | |||
need to clarify | Charts and Charting in Excel | |||
clarify | Excel Programming |