Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formatting a row of Cells

I have written a Macro to record Registration information for up to 2,000
people registered at a Lions Convention.

I use a userform to enter the information for each Registration. Based on
the type of Registration, I would like to be able to highlight the LastRow
in an appropriate color. Since the database is dynamic, I am having
difficulty selecting the Last row (Uses A(lastRow):l(Lastrow)). This is the
code I have written (albeit not well) so far. It will highlight the very
first cell in the LastRow but will not select entire row.

If anyone can steer me straight I would appreciate it.

My Code
=================================
Private Sub CommandButton1_Click()


Dim LastRow As Object
Dim Response As String
Dim Ts As Integer, Lu As Integer, Sheets2 As Worksheet

' Application.Visible = False
Set LastRow = Sheet1.Range("a65536").End(xlUp)

Ts = 0
Lu = 0
If Sheets.Count < 1 Then Sheets(1).Activate
LastRow.Activate

LastRow.Offset(1, 0).Value = txtName.Text
LastRow.Offset(1, 1).Value = txtClub.Text
LastRow.Offset(1, 2).Value = cmbDist.Text
LastRow.Offset(1, 3).Value = 1 ' txtPersons.Text

On Error Resume Next

If CheckBox1 = True Or CheckBox2 = True Then
LastRow.Offset(1, 4).Value = 10
Else
LastRow.Offset(1, 4).Value = 20
End If

If CheckBox1 = True Then
MsgBox ("Sun Only - No Room deposit required!")
LastRow.Offset(1, 5).Value = ""
End If

If CheckBox2 = True Then
MsgBox ("This is a Leo - Registration is only One Half!")

Else
LastRow.Offset(1, 5).Value = txtRoomDep.Text
End If

LastRow.Offset(1, 8).Value = txtLunch.Text
Lu = LastRow.Offset(1, 8).Value * 25
Ts = Ts + Lu
LastRow.Offset(1, 9).Value = txtTheatre.Text
Lu = LastRow.Offset(1, 9).Value * 30
Ts = Ts + Lu
LastRow.Offset(1, 10).Value = txtBanquet.Text
Lu = LastRow.Offset(1, 10).Value * 55
Ts = Ts + Lu
LastRow.Offset(1, 11).Value = txtDance.Text
Lu = LastRow.Offset(1, 11).Value * 5
Ts = Ts + Lu
' LastRow.Offset(1, 12).Value = txtPDG.Text
' Lu = LastRow.Offset(1, 12).Value * 20
' Ts = Ts + Lu
LastRow.Offset(1, 6).Value = Ts

If OptionButton1 = True Then
LastRow.Offset(1, 14).Value = "M" ' Using Master Card
End If
If OptionButton2 = True Then
LastRow.Offset(1, 14).Value = "V" ' Using Visa
End If
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Activate

MsgBox ("The Last row booked is " & LastRow())
' Sheets(1).Activate
Range.Cells("A(LastRow):L(LastRow)").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
' .Strikethrough = False
' .Superscript = False
' .Subscript = False
' .OutlineFont = False
' .Shadow = False
' .Underline = xlUnderlineStyleNone
.ColorIndex = 10
End With


MsgBox "One record written to Sheet1"


================================================== ===

DennisB


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Formatting a row of Cells

Try

Range.Cells("A" & LastRow & ":L" & LastRow).Select


--

HTH

RP
(remove nothere from the email address if mailing direct)


"DennisB" wrote in message
.. .
I have written a Macro to record Registration information for up to 2,000
people registered at a Lions Convention.

I use a userform to enter the information for each Registration. Based on
the type of Registration, I would like to be able to highlight the LastRow
in an appropriate color. Since the database is dynamic, I am having
difficulty selecting the Last row (Uses A(lastRow):l(Lastrow)). This is

the
code I have written (albeit not well) so far. It will highlight the very
first cell in the LastRow but will not select entire row.

If anyone can steer me straight I would appreciate it.

My Code
=================================
Private Sub CommandButton1_Click()


Dim LastRow As Object
Dim Response As String
Dim Ts As Integer, Lu As Integer, Sheets2 As Worksheet

' Application.Visible = False
Set LastRow = Sheet1.Range("a65536").End(xlUp)

Ts = 0
Lu = 0
If Sheets.Count < 1 Then Sheets(1).Activate
LastRow.Activate

LastRow.Offset(1, 0).Value = txtName.Text
LastRow.Offset(1, 1).Value = txtClub.Text
LastRow.Offset(1, 2).Value = cmbDist.Text
LastRow.Offset(1, 3).Value = 1 ' txtPersons.Text

On Error Resume Next

If CheckBox1 = True Or CheckBox2 = True Then
LastRow.Offset(1, 4).Value = 10
Else
LastRow.Offset(1, 4).Value = 20
End If

If CheckBox1 = True Then
MsgBox ("Sun Only - No Room deposit required!")
LastRow.Offset(1, 5).Value = ""
End If

If CheckBox2 = True Then
MsgBox ("This is a Leo - Registration is only One Half!")

Else
LastRow.Offset(1, 5).Value = txtRoomDep.Text
End If

LastRow.Offset(1, 8).Value = txtLunch.Text
Lu = LastRow.Offset(1, 8).Value * 25
Ts = Ts + Lu
LastRow.Offset(1, 9).Value = txtTheatre.Text
Lu = LastRow.Offset(1, 9).Value * 30
Ts = Ts + Lu
LastRow.Offset(1, 10).Value = txtBanquet.Text
Lu = LastRow.Offset(1, 10).Value * 55
Ts = Ts + Lu
LastRow.Offset(1, 11).Value = txtDance.Text
Lu = LastRow.Offset(1, 11).Value * 5
Ts = Ts + Lu
' LastRow.Offset(1, 12).Value = txtPDG.Text
' Lu = LastRow.Offset(1, 12).Value * 20
' Ts = Ts + Lu
LastRow.Offset(1, 6).Value = Ts

If OptionButton1 = True Then
LastRow.Offset(1, 14).Value = "M" ' Using Master Card
End If
If OptionButton2 = True Then
LastRow.Offset(1, 14).Value = "V" ' Using Visa
End If
Set LastRow = Sheet1.Range("a65536").End(xlUp)
LastRow.Activate

MsgBox ("The Last row booked is " & LastRow())
' Sheets(1).Activate
Range.Cells("A(LastRow):L(LastRow)").Select
With Selection.Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
' .Strikethrough = False
' .Superscript = False
' .Subscript = False
' .OutlineFont = False
' .Shadow = False
' .Underline = xlUnderlineStyleNone
.ColorIndex = 10
End With


MsgBox "One record written to Sheet1"


================================================== ===

DennisB




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
Formatting cells Danny Excel Discussion (Misc queries) 2 November 19th 09 03:53 AM
condionally formatting based on another cells formatting? Derrick Excel Discussion (Misc queries) 2 July 31st 09 08:05 PM
conditionally formatting cells based on other cells Derrick Excel Discussion (Misc queries) 1 July 7th 09 09:43 PM
Formatting cells in a column with conditional formatting? shamor Excel Discussion (Misc queries) 8 May 19th 08 10:11 PM
Conditional Formatting Multiple cells based on 2 cells Louis Markowski Excel Worksheet Functions 2 June 1st 05 05:26 PM


All times are GMT +1. The time now is 09:57 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"