0

Hi Guys now ive heard using select and case statements can come with some problems however it is the only way i know how and i need to keep this project as simple as possible so other people who don't really know what there doing like me can update the code this is what i have so far please

Select Case True
Case Range("a1") = "One" And Range("a2") = "full"
    Rows("56:83").Select
    Selection.EntireRow.Hidden = True
    Range("A1:j1").Select
    Range("A2") = "(Change Form Type)"
    Range("A3") = "One"

I know this is probably completely wrong well at least it must be a bit as it doesn't work however hopefully you can see the logic im going for

TIA Dan

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
cizwiz
  • 5
  • 1
  • 9
  • 1
    You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ Feb 25 '20 at 09:59
  • 1
    What is the issue with your code? Any Errors? What did you expect from your code and what did it do instead? What is your question? • Reading [ask] might help to improve your question. – Pᴇʜ Feb 25 '20 at 10:00
  • No errors just doesnt do anything i basically need a way to run code if something is true in one cell and true in another cell – cizwiz Feb 25 '20 at 10:03
  • Probably it is affecting the wrong worksheet? Checkout the link in my first comment and specify a worksheet for every `Range` and `Rows` object. Avoid using `Selection` and `.Select` at any cost. • Try to fix that and if it doesn't solve your issue come back with the relevant code and an example (see [mcve]). – Pᴇʜ Feb 25 '20 at 10:06
  • If it doesn't run your two conditions are not met. – SJR Feb 25 '20 at 10:09

1 Answers1

0

What about this solution (not tested):

If (Range("A1") = "One") And (Range("A2") = "full") Then
  Rows("56:83").EntireRow.Hidden = True
  Range("A2") = "(Change Form Type)"
  Range("A3") = "One"
  Range("A1:J1").Select
End If

Two questions:

  1. What's the point of selecting A1:J1?
  2. Are you sure about the casing of A1 and A2 (uppercase, lowercase)?
Dominique
  • 16,450
  • 15
  • 56
  • 112