Lux Aeterna
Board Regular
- Joined
- Aug 27, 2015
- Messages
- 201
- Office Version
- 2019
- Platform
- Windows
I suppose this is a really long shot, but you guys here can make miracles!
There's an excel workbook that contains three sheets. One named List2022, one named List2023 and one named Results. Next year we'll add a List2024 sheet and so on.
In the results sheet there's a macro that copies a cell to the List2022 sheet.
The macro is here
What I need is an adjustment to the macro so that List2022 changes according to the value of cell Y2 of the result sheets.
So, if Results Y2 is 2022 I need the data from result sheets to be copied to the List2022 sheet. If Results Y2 is 2023 I need the data from result sheets to be copied to the List2023 sheet and so on for each new sheet I add.
Hope that's possible!
Thanks in advance and happy holidays to everyone.
There's an excel workbook that contains three sheets. One named List2022, one named List2023 and one named Results. Next year we'll add a List2024 sheet and so on.
In the results sheet there's a macro that copies a cell to the List2022 sheet.
The macro is here
VBA Code:
Sub ÁðïèÞêåõóç()
Application.ScreenUpdating = False
Dim ID As Range, sup As String, sID As String
If Sheets("Results").Range("U2") = "" Then
MsgBox ("Ôï ID äåí ìðïñåß íá åßíáé êåíü.")
Sheets("Results").Range("U2").Select
Exit Sub
End If
If Sheets("Results").Range("U3") = "" Then
MsgBox ("Ôï êßôñéíï êåëß äåí ìðïñåß íá åßíáé êåíü.")
Sheets("Results").Range("U3").Select
Exit Sub
End If
Set ID = Sheets("List2022").Range("A:A").Find(Sheets("Results").Range("U2").Value, LookIn:=xlValues, lookat:=xlWhole)
If Not ID Is Nothing Then
If ID.Offset(, 1) <> "" Then
If MsgBox("Ôï áðïôÝëåóìá Ý÷åé Þäç äïèåß áðü " & ID.Offset(, 37) & "." & Chr(10) _
& "Èåò ïðùóäÞðïôå íá ôï áíôéêáôáóôÞóåéò;", vbYesNo + vbDefaultButton2) = vbYes Then
ID.Offset(, 1) = Sheets("Results").Range("AB9")
Else
Sheets("Results").Range("U2:X3").ClearContents
Sheets("Results").Range("U2:X2").Select
MsgBox ("Âåâáéþóïõ üôé ôá óôïé÷åßá ðïõ êáôá÷þñçóåò áöïñïýí ôï óùóôü äåßãìá! Áí ü÷é, ðÜôá êáèáñéóìü!")
Exit Sub
End If
Else
ID.Offset(, 1) = Sheets("Results").Range("AB9")
End If
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="C:\Users\pc50\Desktop\New results\" & Range("AH1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Else
MsgBox ("Ôï ID " & Sheets("Results").Range("U2") & " äåí õðÜñ÷åé óôç ëßóôá ôùí List2022." & Chr(10) & "¸ëåãîå üôé Ýâáëåò ôï óùóôü ID.")
Sheets("Results").Range("U2:X3").ClearContents
Sheets("Results").Range("U2:X2").Select
Exit Sub
End If
Application.ScreenUpdating = True
End Sub
What I need is an adjustment to the macro so that List2022 changes according to the value of cell Y2 of the result sheets.
So, if Results Y2 is 2022 I need the data from result sheets to be copied to the List2022 sheet. If Results Y2 is 2023 I need the data from result sheets to be copied to the List2023 sheet and so on for each new sheet I add.
Hope that's possible!
Thanks in advance and happy holidays to everyone.