LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default LastCell Function

Hey everyone,

I am using the lastcell function to take input from a user
form and place it into a spreadsheet that accumulates
entry by entry and the lastcell function allows me to work
from the bottom up. The problem that I am facing is that
not every column will have an entry, so when I go to the
next line, it moves up a few rows to a couple of entries
prior. So I need help on how to program it so that it
finds the last cell and then just works its way to the
right from there. So say it finds that A12 was the last
entry, it will offset by one and then I would like for it
to work its way to the right, like offset(1,0) or
something. Here is the code that I am working with.

Thanks in advance for any help or direction that you can
give.

Private Sub cmdAdd_Click()

Dim LastCell As Range

Sheets("Charlotte").Activate
With ActiveSheet
Set LastCell = .Cells(.Rows.Count, "B").End(xlUp)
If IsEmpty(LastCell) Then
'do nothing
Else
Set LastCell = LastCell.Offset(1, 0)
End If
End With

LastCell.Value = txtPONumber.Value
Set LastCell = LastCell.Offset(0, 1)
LastCell.Value = txtPODate.Value
Set LastCell = LastCell.Offset(0, 1)
LastCell.Value = cmboSales.Value
Set LastCell = LastCell.Offset(0, 1)
LastCell.Value = txtPOAmount.Value
Set LastCell = LastCell.Offset(0, 1)
LastCell.Value = txtPOPercent.Value
Set LastCell = LastCell.Offset(0, 1)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
With ActiveSheet

If cmboVendor.Value = "Airguard" Then

Set LastCell = .Cells(.Rows.Count, "h").End(xlUp)
Set LastCell = LastCell.Offset(1, 0)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
Else

With ActiveSheet
If cmboVendor.Value = "Calmac" Then

Set LastCell = .Cells(.Rows.Count, "i").End(xlUp)
Set LastCell = LastCell.Offset(1, 0)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
Else
With ActiveSheet
If cmboVendor.Value = "Calmac-Polaris" Then

Set LastCell = .Cells(.Rows.Count, "j").End(xlUp)
Set LastCell = LastCell.Offset(1, 0)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
Else
With ActiveSheet
If cmboVendor.Value = "Cambridgeport" Then

Set LastCell = .Cells(.Rows.Count, "k").End(xlUp)
Set LastCell = LastCell.Offset(1, 0)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
Else
With ActiveSheet
If cmboVendor.Value = "CleanPak" Then

Set LastCell = .Cells(.Rows.Count, "l").End(xlUp)
Set LastCell = LastCell.Offset(1, 0)
LastCell.Value = ((txtPOAmount.Value) *
((txtPOPercent.Value) / 100))
Else
MsgBox "still in process", vbOKOnly
End If
End With
End If
End With
End If
End With
End If
End With
End If
End With

End Sub
 
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
copy of excel file not showing formulal/function in the function b oaallam Excel Discussion (Misc queries) 4 September 6th 07 01:20 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel 2007 BUG UsedRange/LastCell differences with Excel2003. keepITcool Excel Discussion (Misc queries) 2 May 31st 06 06:18 PM
Offset function with nested match function not finding host ss. MKunert Excel Worksheet Functions 1 March 21st 06 10:46 PM
Adding a custom function to the default excel function list DonutDel Excel Programming 3 November 21st 03 03:41 PM


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

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"