Dim text on other cell value

apgmin

Board Regular
Joined
Mar 1, 2010
Messages
150
Office Version
  1. 2013
Platform
  1. Windows
I have in Column A, list of questions, In column B the students fill the answers, adjacent to that question. Say the first question is in Cell A1 and the answer is to be put in Cell B1

What should I do to make question in all other cells in column A invisible except the question in Cell A2 , till the value is put in Cell B1

Similarly, What should I do to make question in all other cells in column A invisible except the question in Cell A1:A3 , till the value is put in Cell B2
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
What a funny idea! But as a former teacher I guess I may know what you mean ;)
Actually the're two ways to solve this problem.

Method one: Use conditional formatting and make the cells you don't want to show text and background the same color. But that's a mess of formulas
Method two needs VBA and a second sheet: With the sheets event Selection Change check the last row if the're answers in column B. If yes copy the next question line from sheet B which you should set to xlVeryHidden.

Your code for sheet A
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim i As Integer, r As Integer

r = Cells(Rows.Count, 1).End(xlUp).Row

    If Cells(2, r) <> "" Then
        Cells(r + 1, 1) = ThisWorkbook.Sheets(2).Cells(r + 1, 1)
    End If
End Sub


Have fun!
 
Last edited:
Upvote 0
I'd use conditional formatting.
Select the answers from A2 (not A1) down. Apply conditional formatting based on a formula (Home tab, Conditional Formatting, New rule) and use the formula:
=B1=""
Note that there are no $ signs in there.
1724067897242.png


Click Format..., then select the Number tab and specify a custom number format of:
:::

and OK out

1724067960850.png
 
Upvote 0
Solution
Better use this one:
VBA Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim r As Integer

r = Cells(Rows.Count, 1).End(xlUp).Row

    If Cells(r, 2) <> "" Then
        Cells(r + 1, 1) = ThisWorkbook.Sheets(2).Cells(r + 1, 1)
    End If

End Sub

Take care so have the source (question) in the same row you want to show it in examination sheet.

Have fun!
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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