Hi All,
I'm trying to get a macro to work.
The code I currently have is below. The code in bold does not work correctly
Ideally, I would like the macro to copy use the input from the "First year of issue" (e.g. 2016/17), and then duplicate it x times below (depending on the value of D27). It should then reduce down the number of tax years depending on the number of tax years of issue.
So, for example, if there were 3 employees, who had 3 tax years of issue, and the first tax year was 2012/13, then the macro should give me
2012/13
2012/13
2012/13
2013/14
2013/14
2013/14
2014/15
2014/15
2014/15
Thanks in advance!
I'm trying to get a macro to work.
The code I currently have is below. The code in bold does not work correctly
Ideally, I would like the macro to copy use the input from the "First year of issue" (e.g. 2016/17), and then duplicate it x times below (depending on the value of D27). It should then reduce down the number of tax years depending on the number of tax years of issue.
So, for example, if there were 3 employees, who had 3 tax years of issue, and the first tax year was 2012/13, then the macro should give me
2012/13
2012/13
2012/13
2013/14
2013/14
2013/14
2014/15
2014/15
2014/15
Thanks in advance!
Rich (BB code):
Sub Button11_Click()
Rows("71").EntireRow.Hidden = False
Dim x As Integer
x = Range("f26").Value
Let RowRange = "72:" & 72 + x
Rows("72:72").Copy Range(RowRange)
For i = 1 To x
Let ControlIdRow = 71 + i
Cells(ControlIdRow, 1).Value = "Employee ID" & i
Cells(ControlIdRow, 2).Value = "[Insert employee name here]"
Cells(ControlIdRow, 3).Value = "[Insert employee NINO here]"
Cells(ControlIdRow, 4).Value = "[Tax year of issue]"
Cells(ControlIdRow, 5).Value = "Insert amount due here for employee " & i
Cells(ControlIdRow, 6).Value = "[Provide a description of the payment]"
Cells(ControlIdRow, 7).Value = "[Select tax rate]"
Next i
Dim y As Integer
y = InputBox("Number of tax years of issue?")
If y = 1 Then
'do nothing
End If
If y > 1 Then
Range("A72").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Do Until y = 1
Range("A" & Rows.count).End(xlUp).Offset(1, 0).PasteSpecial
y = y - 1
Loop
Application.CutCopyMode = False
End If
Sheets("Input Sheet").Range("D72").Value = InputBox("Enter the first tax year of issue")
Dim Myvalue As Long
Myvalue = Range("f26").Value
Dim Fy As Long
Dim Ly As Long
Fy = Mid(D72, -2, 2)
Ly = Mid(D72, D72 + 1, 2)
Dim changeCounter As Long
Dim allEmp As Long
Dim P As Integer
P = 1
changeCounter = 0
For P = 1 To x
Dim integerhold As Integer
cell.Value = texttopaste
integerhold = "RoundUp(changeCounter / F26 + 1, 0)"
Next
If intgerhold <> P Then
Fy = Fy + 1
Ly = Ly + 1
cell.Value = texttopaste
End If
End Sub
Last edited by a moderator: