macro to start the data on a specific row

Trout67

New Member
Joined
Feb 8, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
HI There;

I am putting a form together and I want my data to start of row 12, but the data starts only on row16.
I am using a form, that when click save, apply the data tot eh spreadsheet named " Database"

This is the code I used.
VBA Code:
Sub reset()

    Dim irow As Long
   
    irow = Sheets("Database").Cells(Rows.Count, 1).End(xlUp).Offset(1).Row
    ' identifying the last row
   
    With frmForm
   
    .txtDate.Value = ""
   
    .cmbShift.Clear
   
    .cmbShift.AddItem "Day 1"
    .cmbShift.AddItem "Day 2"
    .cmbShift.AddItem "Day 3"
    .cmbShift.AddItem "Day 4"
    .cmbShift.AddItem "Day 5"
    .cmbShift.AddItem "Day 6"
    .cmbShift.AddItem "Day 7"
    .cmbShift.AddItem "Day 8"
    .cmbShift.AddItem "Day 9"
    .cmbShift.AddItem "Day 10"
    .cmbShift.AddItem "Night 1"
    .cmbShift.AddItem "Night 2"
    .cmbShift.AddItem "Night 3"
    .cmbShift.AddItem "Night 4"
    .cmbShift.AddItem "Night 5"
    .cmbShift.AddItem "Night 6"
    .cmbShift.AddItem "Night 7"
    .cmbShift.AddItem "Night 8"
    .cmbShift.AddItem "Night 9"
    .cmbShift.AddItem "Night 10"
   
    .txtTimeIn.Value = ""
    .txtTimeOut.Value = ""
   
    .cmbId.Clear
   
   
    .cmbId.AddItem "2500-MOD-0001"
    .cmbId.AddItem "2400-MOD-0001"
    .cmbId.AddItem "2300-MOD-0001"
   
   
    .cmbStow.Clear
   
   
    .cmbStow.AddItem "WD-FWD"
    .cmbStow.AddItem "WD-MID"
    .cmbStow.AddItem "WD-AFT"
    .cmbStow.AddItem "TWD-FWD"
    .cmbStow.AddItem "TWD-MID"
    .cmbStow.AddItem "TWD-AFT"
    .cmbStow.AddItem "LH-FWD"
    .cmbStow.AddItem "LH-MID"
    .cmbStow.AddItem "LH-AFT"
   
   
    .TxtComm.Value = ""
   
    .lstdatabase.ColumnCount = 7
    .lstdatabase.ColumnHeads = True
   
    .lstdatabase.ColumnWidths = "90,90,90,90,110,90,220"
   
    If irow > 1 Then
   
        .lstdatabase.RowSource = "Database!A12:G" & irow
   
    Else
   
    .lstdatabase.RowSource = "Database!A12:G12"
   
    End If
     
   
    End With
  

End Sub

Sub Submit()

    Dim sh As Worksheet
    Dim irow As Long
   
    Set sh = ThisWorkbook.Sheets("Database")
   
    irow = [counta(Database!a:a)] + 1
   
    With sh
   
    .Cells(irow, 1) = irow - 1
   
    .Cells(irow, 1) = frmForm.txtDate.Value
    .Cells(irow, 2) = frmForm.cmbShift.Value
    .Cells(irow, 3) = frmForm.txtTimeIn.Value
    .Cells(irow, 4) = frmForm.txtTimeOut.Value
    .Cells(irow, 5) = frmForm.cmbId.Value
    .Cells(irow, 6) = frmForm.cmbStow.Value
    .Cells(irow, 7) = frmForm.TxtComm.Value
   

    End With
   

End Sub


Sub Show_Form()

    frmForm.Show

End Sub


Appreciate the help.
 
Last edited by a moderator:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I tried that, but maybe have placed in the correct place within the code.
 
Upvote 0
This is a snap of the datasheet, the actual data is just to place hold, as you can see only starts on row 16.

Thank you for your asssitance.


1644385429631.png
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top