PC Review


Reply
Thread Tools Rate Thread

Enter data in correct row from form

 
 
=?Utf-8?B?U3R1YXJ0?=
Guest
Posts: n/a
 
      10th Apr 2007
Hi guys need your expert help again.

I have created a form that takes a part number and looks this up in a range
and fills the remaining text boxes on the form. So far so good.

What I want to do is, if the user alters the data return this to the row
where I first looked up the original data.

I've searched through but can't find a way of doing it.

my code so far:
TextBox2.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 3, False)
TextBox3.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 2, False)
TextBox4.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 4, False)
TextBox5.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 5, False)
TextBox6.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 6, False)


Then button 2 would use more code to overwrite the old data with the new.

TIA

Stu
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Apr 2007
Dim res as Variant
res = Application.Match(TextBox1.Value, Sheets("QKIT -
NET").Range("B2:G65536"), 0)
if not res is nothing then
set rng = Sheets("QKIT - NET").Range("B2:B65536")(res)
rng.offset(0,2) = TextBox2.Value
rng.offset(0,1) = TextBox3.Value
rng.offset(0,3) = TextBox4.Value
rng.offset(0,4) = TextBox5.Value
rng.offset(0,5) = TextBox6.Value
End if

--
Regards,
Tom Ogilvy

"Stuart" wrote:

> Hi guys need your expert help again.
>
> I have created a form that takes a part number and looks this up in a range
> and fills the remaining text boxes on the form. So far so good.
>
> What I want to do is, if the user alters the data return this to the row
> where I first looked up the original data.
>
> I've searched through but can't find a way of doing it.
>
> my code so far:
> TextBox2.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 3, False)
> TextBox3.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 2, False)
> TextBox4.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 4, False)
> TextBox5.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 5, False)
> TextBox6.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 6, False)
>
>
> Then button 2 would use more code to overwrite the old data with the new.
>
> TIA
>
> Stu

 
Reply With Quote
 
 
 
 
=?Utf-8?B?U3R1YXJ0?=
Guest
Posts: n/a
 
      10th Apr 2007
Tom,
thanks for the info it's much appreciated however bearing in mind you are
helping very much a novice...

I presume that line 2 and 3 have to be joined because of the message limits
but what about line 4/5?

If I join them Vba complains 'end if without block if' and if i don't it
tells me it needs an object?

Stu

"Tom Ogilvy" wrote:

> Dim res as Variant
> res = Application.Match(TextBox1.Value, Sheets("QKIT -
> NET").Range("B2:G65536"), 0)
> if not res is nothing then
> set rng = Sheets("QKIT - NET").Range("B2:B65536")(res)
> rng.offset(0,2) = TextBox2.Value
> rng.offset(0,1) = TextBox3.Value
> rng.offset(0,3) = TextBox4.Value
> rng.offset(0,4) = TextBox5.Value
> rng.offset(0,5) = TextBox6.Value
> End if
>
> --
> Regards,
> Tom Ogilvy
>
> "Stuart" wrote:
>
> > Hi guys need your expert help again.
> >
> > I have created a form that takes a part number and looks this up in a range
> > and fills the remaining text boxes on the form. So far so good.
> >
> > What I want to do is, if the user alters the data return this to the row
> > where I first looked up the original data.
> >
> > I've searched through but can't find a way of doing it.
> >
> > my code so far:
> > TextBox2.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 3, False)
> > TextBox3.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 2, False)
> > TextBox4.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 4, False)
> > TextBox5.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 5, False)
> > TextBox6.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 6, False)
> >
> >
> > Then button 2 would use more code to overwrite the old data with the new.
> >
> > TIA
> >
> > Stu

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Apr 2007
Line 2/3 is pretty much in the form you posted it. I have added a line
continuation character to make two separate lines that constitute one
command. Now all lines should be left as seen

Dim res as Variant
res = Application.Match(TextBox1.Value, _
Sheets("QKIT - NET").Range("B2:G65536"), 0)
if not res is nothing then
set rng = Sheets("QKIT - NET" _
).Range("B2:B65536")(res)
rng.offset(0,2) = TextBox2.Value
rng.offset(0,1) = TextBox3.Value
rng.offset(0,3) = TextBox4.Value
rng.offset(0,4) = TextBox5.Value
rng.offset(0,5) = TextBox6.Value
End if

--
Regards,
Tom Ogilvy

"Stuart" wrote:

> Tom,
> thanks for the info it's much appreciated however bearing in mind you are
> helping very much a novice...
>
> I presume that line 2 and 3 have to be joined because of the message limits
> but what about line 4/5?
>
> If I join them Vba complains 'end if without block if' and if i don't it
> tells me it needs an object?
>
> Stu
>
> "Tom Ogilvy" wrote:
>
> > Dim res as Variant
> > res = Application.Match(TextBox1.Value, Sheets("QKIT -
> > NET").Range("B2:G65536"), 0)
> > if not res is nothing then
> > set rng = Sheets("QKIT - NET").Range("B2:B65536")(res)
> > rng.offset(0,2) = TextBox2.Value
> > rng.offset(0,1) = TextBox3.Value
> > rng.offset(0,3) = TextBox4.Value
> > rng.offset(0,4) = TextBox5.Value
> > rng.offset(0,5) = TextBox6.Value
> > End if
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> > "Stuart" wrote:
> >
> > > Hi guys need your expert help again.
> > >
> > > I have created a form that takes a part number and looks this up in a range
> > > and fills the remaining text boxes on the form. So far so good.
> > >
> > > What I want to do is, if the user alters the data return this to the row
> > > where I first looked up the original data.
> > >
> > > I've searched through but can't find a way of doing it.
> > >
> > > my code so far:
> > > TextBox2.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 3, False)
> > > TextBox3.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 2, False)
> > > TextBox4.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 4, False)
> > > TextBox5.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 5, False)
> > > TextBox6.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 6, False)
> > >
> > >
> > > Then button 2 would use more code to overwrite the old data with the new.
> > >
> > > TIA
> > >
> > > Stu

 
Reply With Quote
 
=?Utf-8?B?U3R1YXJ0?=
Guest
Posts: n/a
 
      11th Apr 2007
So I'm being dumb Tom!

When I run this it fails at the line starting "If not res..." with the error
object required.

What on earth am I doing wrong?

"Tom Ogilvy" wrote:

> Line 2/3 is pretty much in the form you posted it. I have added a line
> continuation character to make two separate lines that constitute one
> command. Now all lines should be left as seen
>
> Dim res as Variant
> res = Application.Match(TextBox1.Value, _
> Sheets("QKIT - NET").Range("B2:G65536"), 0)
> if not res is nothing then
> set rng = Sheets("QKIT - NET" _
> ).Range("B2:B65536")(res)
> rng.offset(0,2) = TextBox2.Value
> rng.offset(0,1) = TextBox3.Value
> rng.offset(0,3) = TextBox4.Value
> rng.offset(0,4) = TextBox5.Value
> rng.offset(0,5) = TextBox6.Value
> End if
>
> --
> Regards,
> Tom Ogilvy
>
> "Stuart" wrote:
>
> > Tom,
> > thanks for the info it's much appreciated however bearing in mind you are
> > helping very much a novice...
> >
> > I presume that line 2 and 3 have to be joined because of the message limits
> > but what about line 4/5?
> >
> > If I join them Vba complains 'end if without block if' and if i don't it
> > tells me it needs an object?
> >
> > Stu
> >
> > "Tom Ogilvy" wrote:
> >
> > > Dim res as Variant
> > > res = Application.Match(TextBox1.Value, Sheets("QKIT -
> > > NET").Range("B2:G65536"), 0)
> > > if not res is nothing then
> > > set rng = Sheets("QKIT - NET").Range("B2:B65536")(res)
> > > rng.offset(0,2) = TextBox2.Value
> > > rng.offset(0,1) = TextBox3.Value
> > > rng.offset(0,3) = TextBox4.Value
> > > rng.offset(0,4) = TextBox5.Value
> > > rng.offset(0,5) = TextBox6.Value
> > > End if
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > > "Stuart" wrote:
> > >
> > > > Hi guys need your expert help again.
> > > >
> > > > I have created a form that takes a part number and looks this up in a range
> > > > and fills the remaining text boxes on the form. So far so good.
> > > >
> > > > What I want to do is, if the user alters the data return this to the row
> > > > where I first looked up the original data.
> > > >
> > > > I've searched through but can't find a way of doing it.
> > > >
> > > > my code so far:
> > > > TextBox2.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > > NET").Range("B2:G65536"), 3, False)
> > > > TextBox3.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > > NET").Range("B2:G65536"), 2, False)
> > > > TextBox4.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > > NET").Range("B2:G65536"), 4, False)
> > > > TextBox5.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > > NET").Range("B2:G65536"), 5, False)
> > > > TextBox6.Value = Application.VLookup(TextBox1.Value, Sheets("QKIT -
> > > > NET").Range("B2:G65536"), 6, False)
> > > >
> > > >
> > > > Then button 2 would use more code to overwrite the old data with the new.
> > > >
> > > > TIA
> > > >
> > > > Stu

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving data from column to row in groups of 250 per row for fourrows, then skip a row and continue the same throughout the data in column A Eric Hess Microsoft Excel Programming 1 11th Jul 2011 11:35 PM
RE: Macro to enter a value, tab to next cell in the row, enter ... Jacob Skaria Microsoft Excel Programming 0 10th Jul 2009 01:54 PM
enter data on 1 sheet and make it enter on next avail row on 2nd s =?Utf-8?B?TmFkaWE=?= Microsoft Excel Misc 27 9th Sep 2005 03:39 PM
Enter user name, enter password, then press enter... =?Utf-8?B?UGF1bCAoRVNJKQ==?= Microsoft Access Forms 6 11th Jul 2005 05:41 PM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Microsoft Excel Programming 1 5th Mar 2004 10:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:28 AM.