View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default LastCell Function

I missed the line that should appear after
End Select

this is:
..Cells(.Rows.Count, col).End(xlUp).Offset(1, 0).Value= _
((txtPOAmount.Value) * ((txtPOPercent.Value) / 100))


You guessed correctly :)

Patrick

-----Original Message-----
The code works great..thanks...however, how do I use the
Selected Case to determine the Column and then place the
value of (txtPOAmount*txtPOPercent\100) in that column?


-----Original Message-----
this might get you started:-


Private Sub cmdAdd_Click()

Dim LastCell As Range

With Sheets("Charlotte")
Set LastCell = .Range("B65000").End(xlUp)
If IsEmpty(LastCell) Then
'do nothing
Else
Set LastCell = LastCell.Offset(1, 0)
End If

LastCell.Value = txtPONumber.Value
LastCell.Offset(0, 1) = txtPODate.Value
Set LastCell = LastCell.Offset(0, 2) =

cmboSales.Value
Set LastCell = LastCell.Offset(0, 3) =
txtPOAmount.Value
Set LastCell = LastCell.Offset(0, 4) =
txtPOPercent.Value
Set LastCell = LastCell.Offset(0, 5) =
((txtPOAmount.Value) * _
((txtPOPercent.Value) /
100))

Dim col As String
Select Case cmboVendor.Value
Case "Airguard": col = "H"
Case "Calmac": col = "i"
Case "Calmac-Polaris": col = "j"
Case "Cambridgeport": col = "k"
Case "CleanPak": col = "L"
Case Else
MsgBox "still in process", vbOKOnly
End Select

End With

End Sub


Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
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
.

.

.