Misunderstanding of Objects please clarify

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
hi,

Range(X) should be a range object not a number of columns
set X = Range("A1")

or
Set X = range("A1:B10")
 
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
 
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.
 
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.
 
I think it's time to post your current code. And indicate what line causes the
trouble.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top