Hide & Add Rows

timesareGMT

New Member
Joined
Aug 19, 2011
Messages
26
HI all,

I'm new in VBA, and I’m trying to make a report layout with the conditions below:

1. If Cell D30 on Sheet 2 = FALSE, automatically hide Row 30 on Sheet 1.
2. If Cell D30 on Sheet 2 = FALSE, automatically add a new row after row 47.

How should I set the code?

Thanks a lot.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
<o:p></o:p>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Sub Geo_BS()
Select Case UCase(Trim(Range("C2").Value))
Case "GEOSPEC 3: 2001 Test 9.4"
Rows("19:35").Hidden = False
Rows("36:48").Hidden = True
Case "BS 1377: Part 3: 1990 Section 7.3"
Rows("19:35").Hidden = True
Rows("36:48").Hidden = False
Case Else
Rows("19:48").Hidden = False
End Select
End Sub

Why it seems impossible to get the macro run if I change combobox info as that highlighted in blue? (The related cells was updated accordingly)

Thanks.
 
Upvote 0
Change this...
Select Case UCase(Trim(Range("C2").Value))

To this...
Select Case Trim(Range("C2").Value)


OR make this all caps.
Case "GEOSPEC 3: 2001 TEST 9.4"
Case "BS 1377: PART 3: 1990 SECTION 7.3"


I included UCase in the original code because I wasn't sure if your list would have GEO or Geo or geo and UCase made it capital letters insensitive. But that means you have to put in the code all caps for the selected items.
 
Upvote 0
Change this...
Select Case UCase(Trim(Range("C2").Value))

To this...
Select Case Trim(Range("C2").Value)


OR make this all caps.
Case "GEOSPEC 3: 2001 TEST 9.4"
Case "BS 1377: PART 3: 1990 SECTION 7.3"


I included UCase in the original code because I wasn't sure if your list would have GEO or Geo or geo and UCase made it capital letters insensitive. But that means you have to put in the code all caps for the selected items.


Solved. Thanks so much!! :-P
 
Upvote 0
I added another new spreadsheet (page 4).

On this page the cell D21 is an outcome of a series of calculations,
1. When D21 < 0.5, rows 23 to 28 will automatically hide.
2. When D21 > 0.5, rows 23 to 28 will automatically show (if they'd hided)

How should I set the VBA code for this?

Thanks for your help.
 
Upvote 0
It comes to spreadsheet protection issue.

When I apply security passwords to the spreadsheets, the assigned macros will then be stopped from running.

How can I solve this problem?

Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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