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
ProgramSub-programTaskResponsible person
Office
SuppliesContact suppliersKevin
OfficeSuppliesPay suppliersJessica
OfficeRecruitmentContact agencies
Home*******Monthly shoppingPaul

<tbody>
</tbody>

Output
ProgramSub-programTask
OfficeRecruitmentContact agencies

<tbody>
</tbody>

Any help much much appreciated! :)
****** id="cke_pastebin" style="position: absolute; top: 214.667px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
ProgramSub-programTask

<tbody>
</tbody>


</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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,216,070
Messages
6,128,614
Members
449,460
Latest member
jgharbawi

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