Feb 07 2024 12:34 AM
Hello, I'm trying to have the excel to work as in subject, I found online a solution and I tried to compile it but it's not working. I want the rows of every sheet except the last one to move to the sheet "RICONSEGNATE" when the column "DATA RICONSEGNA FORNITORE" is filled with any date. Can you please help me to figure it out?
Feb 07 2024 02:17 AM
I'd be happy to help you set up an Excel macro that automatically moves entire rows to another sheet when a cell in "DATA RICONSEGNA FORNITORE" is filled with any date, excluding the last sheet. Here's the code along with explanations:
Sub MoveRowsWhenFilled()
' Declare variables
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim lastRow As Long
Dim cellValue As Variant
' Define the target sheet name
Set targetSheet = Sheets("RICONSEGNATE")
' Loop through all worksheets except the last one
For Each sourceSheet In Sheets
If sourceSheet.Index <> Sheets.Count Then ' Skip the last sheet
' Find the last row of data in the source sheet
lastRow = sourceSheet.Cells(Rows.Count, 1).End(xlUp).Row
' Loop through each row in the source sheet
For i = 2 To lastRow ' Start from row 2 to avoid headers
' Check if the cell in "DATA RICONSEGNA FORNITORE" is filled with a date
cellValue = sourceSheet.Cells(i, "DATA RICONSEGNA FORNITORE").Value
If IsDate(cellValue) Then ' Check if it's a valid date
' Move the entire row to the target sheet
sourceSheet.Rows(i).EntireRow.Cut
targetSheet.Cells(targetSheet.Rows.Count, 1).End(xlUp).Offset(1).EntireRow.Insert
End If
Next i
End If
Next sourceSheet
End Sub
Explanation:
How to use:
To run manually:
Important notes:
I hope this refined code effectively addresses your requirement and provides a clear solution!
Feb 12 2024 04:10 AM
I tried to figure it out but I couldn't make it work. Could you please set it up? Consider that for the sheets "MISCELA NUCLEARE -AZOTO" and "GAS CAMPIONE" the column "DATA RICONSEGNA FORNITORE" is M and not K. You can find the file in attachment. Thanks in advance.
Feb 13 2024 03:30 AM
I can still help you with the formula based on the information you provided. Please share the following details:
With this information, I can diagnose the problem and provide a revised formula that works correctly for all sheets, taking into account the different column positions for "DATA RICONSEGNA FORNITORE".
Additionally, if you have any specific requirements or preferences for the output of the formula, feel free to share them as well. The more information you can provide, the better I can assist you.
I tried to attach an Excel file to help with your Excel sheet.
Feb 14 2024 09:03 AM
Since it's the first time I try to execute a macro, I don't know if I'm doing things right. I tried to follow your istructions, meaning that I saved the code in a VBA module but I don't know how to place the macro in the workbook to run automatically. In attachment you can see the excel that I modified but something is missing, I think. For what concerns "MISCELA NUCLEARE -AZOTO" and "GAS CAMPIONE" sheets, the only difference with the other sheets is that the column "DATA RICONSEGNA FORNITORE" is not K but M. I hope I have been clear enough.