Two part problem: 1- If a cell in a column in blank, return value in a cell in the same row, but different column

excellearner17

New Member
Joined
Nov 10, 2017
Messages
6
Second part is based on the row number of the returned cell value, match other two columns. Maybe an example will make this more clear:

From the raw data I want to extract the program name whenever there is no responsible person assigned (cell blank), After I want to be able to match the sub-program and task with the right program
Key facts:
- The list is long, so I need a formula that can continue to scan down, even if more rows are added
- The raw data and output will be in separate tabs

Raw data[TABLE="width: 500"]
<tbody>[TR]
[TD]Program[/TD]
[TD]Sub-program[/TD]
[TD]Task[/TD]
[TD]Responsible person[/TD]
[/TR]
[TR]
[TD]Office
[/TD]
[TD]Supplies[/TD]
[TD]Contact suppliers[/TD]
[TD]Kevin
[/TD]
[/TR]
[TR]
[TD]Office[/TD]
[TD]Supplies[/TD]
[TD]Pay suppliers[/TD]
[TD]Jessica[/TD]
[/TR]
[TR]
[TD]Office[/TD]
[TD]Recruitment[/TD]
[TD]Contact agencies[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Home[/TD]
[TD]*******[/TD]
[TD]Monthly shopping[/TD]
[TD]Paul[/TD]
[/TR]
</tbody>[/TABLE]

Output
[TABLE="width: 500"]
<tbody>[TR]
[TD]Program[/TD]
[TD]Sub-program[/TD]
[TD]Task[/TD]
[/TR]
[TR]
[TD]Office[/TD]
[TD]Recruitment[/TD]
[TD]Contact agencies[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Any help much much appreciated! :)
****** id="cke_pastebin" style="position: absolute; top: 214.667px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="width: 500"]
<tbody>[TR]
[TD]Program[/TD]
[TD]Sub-program[/TD]
[TD]Task[/TD]
[/TR]
</tbody>[/TABLE]


</body>
 
Hi,

Could I have it updated with all three options? Also is there any downside or thing I need to be aware of using macros?
For example, I have another table to create which has a similar problem to this - could I use the same macro multiple times?
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Place the following 3 macros in the code module for ThisWorkbook:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Sheet2").UsedRange.ClearContents
    Sheets("Sheet1").Rows(1).EntireRow.Copy Sheets("Sheet2").Cells(1, 1)
    Sheets("Sheet1").Range("A1:D" & LastRow).AutoFilter Field:=4, Criteria1:="="
    Sheets("Sheet1").Range("A2:D" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1, 0)
    If Sheets("Sheet1").AutoFilterMode = True Then Sheets("Sheet1").AutoFilterMode = False
    Application.ScreenUpdating = True
End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Sheet2").UsedRange.ClearContents
    Sheets("Sheet1").Rows(1).EntireRow.Copy Sheets("Sheet2").Cells(1, 1)
    Sheets("Sheet1").Range("A1:D" & LastRow).AutoFilter Field:=4, Criteria1:="="
    Sheets("Sheet1").Range("A2:D" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1, 0)
    If Sheets("Sheet1").AutoFilterMode = True Then Sheets("Sheet1").AutoFilterMode = False
    Application.ScreenUpdating = True
End Sub

Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Sheets("Sheet2").UsedRange.ClearContents
    Sheets("Sheet1").Rows(1).EntireRow.Copy Sheets("Sheet2").Cells(1, 1)
    Sheets("Sheet1").Range("A1:D" & LastRow).AutoFilter Field:=4, Criteria1:="="
    Sheets("Sheet1").Range("A2:D" & LastRow).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "A").End(xlUp).Offset(1, 0)
    If Sheets("Sheet1").AutoFilterMode = True Then Sheets("Sheet1").AutoFilterMode = False
    Application.ScreenUpdating = True
End Sub
You will notice that they are exactly the same except for the type of event. You can unse the same macros multiple times provided that the data in your worksheet is organized in an identical manner as your current data.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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