Hi everyone
So I posted in here a few weeks ago and someone wrote me an excellent VBA which cuts and pastes rows to different sheets depending on what's written in column F of my workbook. The code is as follows:
Since then, I have added some more data to the workbook. For this reason, I have run into a few more problems: when I run the VBA, it cuts and pastes the rows as desired; however, this also means that it cuts cells I14, I15, I17, and I18 as a result. It also moves the macro button and the image. Before, there was nothing in these cells so it didn't matter. However, as they now contain data that I need - it's important that they stay in the same position when the VBA runs. The same applies to the macro button and the image - I need these to stay in the same place: if these cells move, the formulas posted below stop working :/
Is there a way of having the VBA run without those cells being cut? Cell I15 contains a drop down list using data validation from the Cycles sheet. I18 includes an XLOOKUP from another workbook.
I only want values in column G and H to appear if column F contains an amount, so I've used the following If Formula:
In column H I've used the following:
Another thing I want to change is the way columns G and H on the Send and Reject tabs look after the VBA has run. As columns G and H will only return values if cells in column F on the Merge sheet have an amount in - blank cells are being copied onto the Send and Reject tab and they always end up looking like this: [please note that I've pasted a shape over some columns for data protection purposes].
Is there a way to prevent the width of columns G and H on the Send and Reject tabs from getting so small - it looks really out of place.
Thanks for all your help!
So I posted in here a few weeks ago and someone wrote me an excellent VBA which cuts and pastes rows to different sheets depending on what's written in column F of my workbook. The code is as follows:
VBA Code:
Sub sort_my_data()
'VBA written by SQUIDD from MrExcel.com
Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual: Application.DisplayAlerts = False: Application.EnableEvents = False
For a = Range("'Merge'!A" & Rows.Count).End(xlUp).Row To 2 Step -1
If Range("'Merge'!f" & a) = "destroy" Then
Rows(a).Copy
Sheets("REJECT").Rows(Sheets("REJECT").Cells(Rows.Count, "A").End(xlUp).Row + 1).PasteSpecial
Rows(a).Delete
End If
If Range("'Merge'!f" & a) = "-" Then
Rows(a).Copy
Sheets("send").Rows(Sheets("send").Cells(Rows.Count, "A").End(xlUp).Row + 1).PasteSpecial
Rows(a).Delete
End If
Next a
For Each ws In ActiveWorkbook.Worksheets
ws.Columns.AutoFit
ws.Rows.AutoFit
Next
Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic: Application.DisplayAlerts = True: Application.EnableEvents = True
End Sub
Since then, I have added some more data to the workbook. For this reason, I have run into a few more problems: when I run the VBA, it cuts and pastes the rows as desired; however, this also means that it cuts cells I14, I15, I17, and I18 as a result. It also moves the macro button and the image. Before, there was nothing in these cells so it didn't matter. However, as they now contain data that I need - it's important that they stay in the same position when the VBA runs. The same applies to the macro button and the image - I need these to stay in the same place: if these cells move, the formulas posted below stop working :/
Is there a way of having the VBA run without those cells being cut? Cell I15 contains a drop down list using data validation from the Cycles sheet. I18 includes an XLOOKUP from another workbook.
Excel Formula:
=XLOOKUP(I15,Cycles.xlsx!$C$4:$C$40, Cycles.xlsx!$D$4:$D$40, " ")
I only want values in column G and H to appear if column F contains an amount, so I've used the following If Formula:
Excel Formula:
=IF(ISNUMBER(F2),$I$15, " ")
In column H I've used the following:
Excel Formula:
=IF(ISNUMBER(F2), $I$18, " ")
Another thing I want to change is the way columns G and H on the Send and Reject tabs look after the VBA has run. As columns G and H will only return values if cells in column F on the Merge sheet have an amount in - blank cells are being copied onto the Send and Reject tab and they always end up looking like this: [please note that I've pasted a shape over some columns for data protection purposes].
Is there a way to prevent the width of columns G and H on the Send and Reject tabs from getting so small - it looks really out of place.
Thanks for all your help!