Automatic copy new rows in sheet. Shooter contest.

HansO

New Member
Joined
Sep 18, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

For my shooter contest I have made an excel for writing down my results. I struggle with adding rows in another sheet of the same workbook.

I start with today (ex. 03-09-2024) and I put my results into set of 10 series (Reeks) each of 5 shots. For every set I compute my points and the percentage.. See screenshot.

1726665153992.png

Every new contest I change the date and add my new results.
The previous data should be copied in another tab Overview (Overzicht) See my screenshot below
1726665533137.png


The Header in Row 1 should be fixed and the previous results must shift down into row 4. So the last result comes in row 3.
Can some one help me?
Kind regards,

Hans
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi Hans and Welcome to the Board! If your data is laid out as displayed, this seems to work. Change the sheet name from "Sheet1" to whatever for your data sheet and place this code in the sheet code. Then run the "Test" sub. HTH. Dave
VBA Code:
Sub test()
Dim DtVar As Date, PtArr() As Variant, PerArr() As Variant, ColCnt As Integer
Dim PtTot As Double, PerAvg As Double, LRow As Integer, ws As Worksheet
Dim ArrCnt As Integer
'store results
With ThisWorkbook.Sheets("Sheet1")
DtVar = .Range("A" & 1)
PtArr = Application.WorksheetFunction.Transpose(Application.WorksheetFunction.Transpose(Range("C7:L7").Value))
PtTot = .Range("M" & 7)
PerArr = Application.WorksheetFunction.Transpose(Application.WorksheetFunction.Transpose(Range("C8:L8").Value))
PerAvg = .Range("M" & 8)
End With

'move results
Set ws = ThisWorkbook.Worksheets("overzicht")
With ws
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
If LRow = 1 Then
LRow = 2
End If
.Cells(LRow + 1, "A").Value = DtVar
.Cells(LRow + 1, "B").Value = "# Pt/%"

ColCnt = 3
For ArrCnt = LBound(PtArr) To UBound(PtArr)
.Cells(LRow + 1, ColCnt) = PtArr(ArrCnt)
ColCnt = ColCnt + 1
.Cells(LRow + 1, ColCnt) = PerArr(ArrCnt)
ColCnt = ColCnt + 1
Next ArrCnt

.Cells(LRow + 1, "W").Value = PtTot
.Cells(LRow + 1, "X").Value = PerAvg
End With
End Sub
 
Upvote 0
Another possibility

Not knowing the sheet name or rows used, I use Double-Click on the date in column "A"
Right click on the tab of the sheet of first picture and select View code
paste this into the editor window that opens.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    
    Dim i As Long, rw As Long, col As Long
    Dim ray(0 To 24)
    
    If Not Intersect(Target, Columns("A")) Is Nothing And IsDate(Target) Then
        ' cancel cell edit mode
        Cancel = True
        ' start loading array
        ray(0) = Target
        ray(1) = "# pt/%"
        ' prep for rest
        rw = Target.Row + 6
        i = 2
        ' loop the cells in the 2 required rows of data
        For col = 3 To 13
            ray(i) = Cells(rw, col)
            i = i + 1
            ray(i) = Cells(rw + 1, col)
            i = i + 1
        Next col
        ' write the array to the other sheet
        With Sheets("overzicht")
            .Rows(3).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
            .Range("A3").Resize(, 24).Value = ray
        End With
        ' message just to know it was done
        MsgBox "Double Click Macro Completed"
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,522
Messages
6,160,314
Members
451,637
Latest member
hvp2262

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