Consulting

Results 1 to 2 of 2

Thread: changing color of cells with vba

  1. #1

    changing color of cells with vba

    hi
    i have this code which finds the first empty row then adds the data to the sheet. what im after then is to change the colour of the row from columns B-L

    [VBA]Private Sub cmdNewRoom_Click()
    Sheets("materials2").Select
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("materials2")

    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 4) _
    .End(xlUp).Offset(1, 0).Row
    ws.Cells(iRow, 2).Value = Me.txtRoomName.Value
    .Interior.Color = RGB(83, 142, 213)
    End Sub[/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]Private Sub cmdNewRoom_Click()
    Sheets("materials2").Select
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("materials2")

    With ws

    'find first empty row in database
    iRow = .Cells(.Rows.Count, 4).End(xlUp).Offset(1, 0).Row
    .Cells(iRow, 2).Value = Me.txtRoomName.Value
    .Interior.Color = RGB(83, 142, 213)
    End With
    End Sub[/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •