Results 1 to 12 of 12

Coding for offset cell references with multiple row headings with merged cells

Threaded View

  1. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Coding for offset cell references with multiple row headings with merged cells

    Hello AndyE,

    I revised your macro after I figured out what you wanted to do. This macro has been added to the user form in the attached workbook.
    Private Sub cmbSubmit_Click()
      
      Dim Rng As Range
      Dim RngEnd As Range
      Dim Wks As Worksheet
      
        Set Wks = Worksheets("Overtime")
    
       'First entry starts at "A4"
        Set Rng = Wks.Range("A4")
        
       'Find the last entry in column "A"
        Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp)
        
       'If last entry is below "A4" then use row 4. Otherwise, use the last entry row + 1
        Set Rng = IIf(RngEnd.Row < Rng.Row, Rng, RngEnd.Offset(1, 0))
        
       'Make the range a single row of 12 columns
        Set Rng = Rng.Resize(ColumnSize:=12)
        
       'Write data to worksheet
        If Me.cboOvertimeType.Value = "" Then
           MsgBox "Please select the type of Overtime worked.", vbExclamation, "Overtime Form"
           Me.cboOvertimeType.SetFocus
        End If
    
          With Rng
            .Item(1).Value = RosStartDatePicker.Value
            .Item(2).Value = VBA.Format(RosStartTimePicker.Value, "hh:mm:ss")
            .Item(3).Value = RosEndDatePicker.Value
            .Item(4).Value = VBA.Format(RosEndTimePicker.Value, "hh:mm:ss")
            .Item(6).Value = ActStartDatePicker.Value
            .Item(7).Value = VBA.Format(ActStartTimePicker.Value, "hh:mm:ss")
            .Item(8).Value = ActEndDatePicker.Value
            .Item(9).Value = VBA.Format(ActEndTimePicker.Value, "hh:mm:ss")
            .Item(12).Value = cboOvertimeType.Value
          End With
    
        Unload Me
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1