Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Kink in locating last row

I use a userform for a user to input item number and qty. With a
commandbutton click event, code is executed to locate the last row and then
place the data into the cells. Because of the layout of the information to
be printed, I am forced to create two sections within the spreadsheet. Let
me explain better.

FORM-1 FORM-2
A13:A50 & G13:G50 = item number
B13:B50 & H13:H50 = qty
C13:C50 & I13:I50 = Item description (pulled from another sheet w/ item
number match)
D13:D50 & J13:J50 = Misc Info about that item

The forms, as you can see, are identical. Once form-1 is filled up, then I
need the to start using form-2. Each form allows for 38 items to be ordered.
The problem is that the code for locating the last row would not work since
the first form is filled up to row 50 and then I start filling the second
form at row 13 again. Below is the code that is used as I described. How do
I go about bypassing the last row as being 50 (or 51 as last empty row) in
order to be able to use the second form?

Dim rng As Range
With Worksheets("Order")
Set rng = .Cells(Rows.Count, 1).End(xlUp)(2)
If rng.Row < 13 Then
Set rng = .Cells(13, 1)
End If
End With
rng.Value = txtItemNum
rng.Offset(0, 1).Value = txtQty

Thanks for your help in advance!
Les
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Kink in locating last row

Dim rng As Range
Dim icol as Long
With Worksheets("Order")
if application.CountA(.Range("A13:A50")) < 38 then
icol = 1
else
icol = 7
End if
Set rng = .Cells(Rows.Count, icol).End(xlUp)(2)
If rng.Row < 13 Then
Set rng = .Cells(13, icol)
End If
End With
rng.Value = txtItemNum
rng.Offset(0, 1).Value = txtQty


--
Regards,
Tom Ogilvy


"WLMPilot" wrote in message
...
I use a userform for a user to input item number and qty. With a
commandbutton click event, code is executed to locate the last row and
then
place the data into the cells. Because of the layout of the information
to
be printed, I am forced to create two sections within the spreadsheet.
Let
me explain better.

FORM-1 FORM-2
A13:A50 & G13:G50 = item number
B13:B50 & H13:H50 = qty
C13:C50 & I13:I50 = Item description (pulled from another sheet w/ item
number match)
D13:D50 & J13:J50 = Misc Info about that item

The forms, as you can see, are identical. Once form-1 is filled up, then
I
need the to start using form-2. Each form allows for 38 items to be
ordered.
The problem is that the code for locating the last row would not work
since
the first form is filled up to row 50 and then I start filling the second
form at row 13 again. Below is the code that is used as I described. How
do
I go about bypassing the last row as being 50 (or 51 as last empty row) in
order to be able to use the second form?

Dim rng As Range
With Worksheets("Order")
Set rng = .Cells(Rows.Count, 1).End(xlUp)(2)
If rng.Row < 13 Then
Set rng = .Cells(13, 1)
End If
End With
rng.Value = txtItemNum
rng.Offset(0, 1).Value = txtQty

Thanks for your help in advance!
Les



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 470
Default Kink in locating last row

Tom,

Thanks for all your help. It works great!!
Les

"Tom Ogilvy" wrote:

Dim rng As Range
Dim icol as Long
With Worksheets("Order")
if application.CountA(.Range("A13:A50")) < 38 then
icol = 1
else
icol = 7
End if
Set rng = .Cells(Rows.Count, icol).End(xlUp)(2)
If rng.Row < 13 Then
Set rng = .Cells(13, icol)
End If
End With
rng.Value = txtItemNum
rng.Offset(0, 1).Value = txtQty


--
Regards,
Tom Ogilvy


"WLMPilot" wrote in message
...
I use a userform for a user to input item number and qty. With a
commandbutton click event, code is executed to locate the last row and
then
place the data into the cells. Because of the layout of the information
to
be printed, I am forced to create two sections within the spreadsheet.
Let
me explain better.

FORM-1 FORM-2
A13:A50 & G13:G50 = item number
B13:B50 & H13:H50 = qty
C13:C50 & I13:I50 = Item description (pulled from another sheet w/ item
number match)
D13:D50 & J13:J50 = Misc Info about that item

The forms, as you can see, are identical. Once form-1 is filled up, then
I
need the to start using form-2. Each form allows for 38 items to be
ordered.
The problem is that the code for locating the last row would not work
since
the first form is filled up to row 50 and then I start filling the second
form at row 13 again. Below is the code that is used as I described. How
do
I go about bypassing the last row as being 50 (or 51 as last empty row) in
order to be able to use the second form?

Dim rng As Range
With Worksheets("Order")
Set rng = .Cells(Rows.Count, 1).End(xlUp)(2)
If rng.Row < 13 Then
Set rng = .Cells(13, 1)
End If
End With
rng.Value = txtItemNum
rng.Offset(0, 1).Value = txtQty

Thanks for your help in advance!
Les




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Locating amesaage Marc W Excel Discussion (Misc queries) 2 September 25th 09 01:58 PM
Locating the max value AND performing a fn on it only Pradhan Excel Discussion (Misc queries) 3 July 22nd 09 01:09 AM
Locating Karmen New Users to Excel 2 January 30th 06 11:45 PM
locating the top 5 number (in a col) owl527 Excel Worksheet Functions 1 January 10th 06 01:35 PM
locating charts Scott Parsons Excel Programming 0 November 11th 03 08:03 PM


All times are GMT +1. The time now is 08:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"