Making code easier to work with at start of new tax year

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,731
Office Version
  1. 2007
Platform
  1. Windows
I have a worksheet that stores all my income / expenses etc & is currently named SUMMARY SHEET 2024-2025.xlsm
I have a workbook which has worksheets like Income 1 Income 2 etc & also Expenses1 Expenses 2 etc etc

When each month ends i send the values from each active sheet of its kind to the summary sheet.
When the new tax year starts i rename the summary sheet with its new current year

My issue is then i need to change each income / expenses sheet also for the new year date of which takes time.

I thought last night to have the 1 code & put in a module & call that module to run that code,thus me only having to change the date once as opposed to many but that didnt work as in the code each sheet name is referenced like INCOME(1) etc etc

Here is the code for Income 1 to show you what i mean.
Do you see a way for me to minimise my work in respect of dates etc.

VBA Code:
Private Sub CommandButton2_Click()
Dim answer As Long, wb As Workbook
    answer = MsgBox("ONLY TRANSFER FIGURES IF ITS THE END OF THE MONTH" & vbNewLine & "" & vbNewLine & "***** DO WE CONTINUE TO TRANSFER THE FIGURES ? *****", vbYesNo + vbCritical, "END OF MONTH TRANSFER QUESTION")
    If answer = vbYes Then
        Set wb = Workbooks.Open(FileName:="C:\Users\Ian\Desktop\EBAY\ACCOUNTS\CURRENT SHEETS\SUMMARY SHEET 2024-2025.xlsm")
        Workbooks("ACCOUNTS.xlsm").Sheets("INCOME (1)").Range("E32").Copy
        wb.Sheets("SUMMARY SHEET").Range("I9").PasteSpecial xlPasteValues
        
        Workbooks("ACCOUNTS.xlsm").Sheets("INCOME (1)").Range("F32").Copy
        wb.Sheets("SUMMARY SHEET").Range("I10").PasteSpecial xlPasteValues
        wb.Close True
        
        Else
        Exit Sub
        
        End If
        Workbooks("ACCOUNTS.xlsm").Sheets("INCOME (1)").Range("A5").Select
        Application.CutCopyMode = False
        MsgBox "SUMMARY TRANSFER COMPLETED", vbInformation, "SUCCESSFUL MESSAGE"
        ActiveWorkbook.Save
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
To maybe overcome an issue & using the code above as an example.

Can this line below be written different ?

VBA Code:
Workbooks("ACCOUNTS.xlsm").Sheets("INCOME (1)").Range("E32").Copy

I ask as not sure why it needs to be so specific as at the end of the day the code copies values from various cells on the active sheet then enters them on the summary sheet.
Basically run the code & what ever values are in the cell in question just copy / paste.
Having the code show INCOME (1) makes it harder hence why i have the same code on each sheet.
If i have completed all the cell values on say INCOME (1) i then continue on the next sheet being INCOME (2) so at the end of the month when i transfer the value i only run the code from INCOME (2) & like i say it copies various cell values off this page to another sheet.
 
Upvote 0
Can we not write something along the lines of With Active Sheet etc then specify the cell to copy value from ?
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

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