Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default find last item in record

i use the code below to find the last record in my workbook. some times it
work without problem some times it goes to the last record even if the first
record is empty. can someone help me with this code. how can i simplify it?

Private Sub MultiPage1_Change()
If MultiPage1.Pages(3).Visible = True Then

'check for last item
Workbooks("Declaration Pro.xls").Worksheets("Classification").Activate
Range("B5").Select
If ActiveCell.Value < "" Then
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Offset(-1, 0).Select
End If
'load controls with last item's value------------
cboTariffNo.Value = ActiveCell.Value
txtDescription.Value = ActiveCell.Offset(0, 1).Value
txtItemFob.Value = ActiveCell.Offset(0, 4).Value
cboCPC.Value = ActiveCell.Offset(0, 18).Value
txtSupplQuantity.Value = ActiveCell.Offset(0, 19).Value
cboCountryOfOrigin.Value = ActiveCell.Offset(0, 20).Value
txtNoPackage.Value = ActiveCell.Offset(0, 21).Value
cboPackageType.Value = ActiveCell.Offset(0, 22).Value
cboEnvSurChar.Value = ActiveCell.Offset(0, 25).Value
txtNetWeight.Value = ActiveCell.Offset(0, 26).Value
lblItemNo.Caption = ActiveCell.Offset(0, -1)
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default find last item in record

something like

lc=cells(rows.count,"b").end(xlup).row
cboTariffNo.value=Cells(lc, 2).Offset(0,0)
txtDescription.Value = cells(lc,2).Offset(0, 1)
etc



--
Don Guillett
SalesAid Software

"ernie" wrote in message
...
i use the code below to find the last record in my workbook. some times it
work without problem some times it goes to the last record even if the
first
record is empty. can someone help me with this code. how can i simplify
it?

Private Sub MultiPage1_Change()
If MultiPage1.Pages(3).Visible = True Then

'check for last item
Workbooks("Declaration Pro.xls").Worksheets("Classification").Activate
Range("B5").Select
If ActiveCell.Value < "" Then
Do
If IsEmpty(ActiveCell) = False Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = True
ActiveCell.Offset(-1, 0).Select
End If
'load controls with last item's value------------
cboTariffNo.Value = ActiveCell.Value
txtDescription.Value = ActiveCell.Offset(0, 1).Value
txtItemFob.Value = ActiveCell.Offset(0, 4).Value
cboCPC.Value = ActiveCell.Offset(0, 18).Value
txtSupplQuantity.Value = ActiveCell.Offset(0, 19).Value
cboCountryOfOrigin.Value = ActiveCell.Offset(0, 20).Value
txtNoPackage.Value = ActiveCell.Offset(0, 21).Value
cboPackageType.Value = ActiveCell.Offset(0, 22).Value
cboEnvSurChar.Value = ActiveCell.Offset(0, 25).Value
txtNetWeight.Value = ActiveCell.Offset(0, 26).Value
lblItemNo.Caption = ActiveCell.Offset(0, -1)
End If
End Sub



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
To find rate of each item from item.xls and to copy price.xls pol Excel Discussion (Misc queries) 7 July 16th 09 12:49 AM
Find Record Box OldGuy Excel Discussion (Misc queries) 1 January 30th 08 07:58 PM
Find record MarkN Excel Worksheet Functions 3 November 9th 06 07:42 AM
Find Record Janis in Minnesota Excel Discussion (Misc queries) 0 September 2nd 05 04:54 PM
Find the Record Syed Haider Ali[_11_] Excel Programming 2 August 21st 05 11:03 PM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"