whats wrong with this?

  • Thread starter brownti via OfficeKB.com
  • Start date
B

brownti via OfficeKB.com

this is my code inside of some other code.

If basedooranswer = "FLUSH HOLLOW CORE" Then
Application.Goto reference:="onepa_ilo_fhc"
Selection.EntireRow.Hidden = False
End If

why doesnt it work?
thanks
 
J

JE McGimpsey

What does "doesnt it work" mean to you?

If

(a) there's a workbook-level named range "onepa_ilo_fhc", or if the
named range is a worksheet-level named range and that worksheet is
active, and

(b) the variable basedooranswer = "FLUSH HOLLOW CORE"

then after the code is run, the sheet containing the referenced range
"onepa_ilo_fhc" should be active and the row(s) referenced by
"onepa_ilo_fhc" should be visible.

Works on a test workbook for me.

However, there are any number of other things that could "not work",
depending on the "other code" and a host of other factors...
 
B

brownti via OfficeKB.com

here is what i have:

a sheet titled "new labels" and a sheet titled "builder" a checkbox on the
sheet builder is supposed to fire the macro:

Sub six_panel()
Application.ScreenUpdating = False
If ("basedooranswer") = "FLUSH HOLLOW CORE" Then
Selection.Goto reference:=("onepa_ilo_fhc")
Selection.EntireRow.Hidden = False
End If
Application.Goto reference:="six_panel"
Selection.EntireRow.Hidden = False
Sheets("builder").Select
Application.ScreenUpdating = True
End Sub

The second part of it works just fine, however it doesnt complete the first
part. "onepa_ilo_fhc" is a row on the sheet "new labels". if more info is
needed i can provide. thanks,



JE said:
What does "doesnt it work" mean to you?

If

(a) there's a workbook-level named range "onepa_ilo_fhc", or if the
named range is a worksheet-level named range and that worksheet is
active, and

(b) the variable basedooranswer = "FLUSH HOLLOW CORE"

then after the code is run, the sheet containing the referenced range
"onepa_ilo_fhc" should be active and the row(s) referenced by
"onepa_ilo_fhc" should be visible.

Works on a test workbook for me.

However, there are any number of other things that could "not work",
depending on the "other code" and a host of other factors...
this is my code inside of some other code.
[quoted text clipped - 5 lines]
why doesnt it work?
thanks
 
J

JE McGimpsey

The text string

"basedooranswer"

(which is NOT a variable) will never equal

"FLUSH HOLLOW CORE"

so the If...Then branch will never be taken.

So fixing it depends on what basedooranswer is supposed to be.

If it's supposed to be a global or module-level variable then you need
to take it out of quotes.


"brownti via OfficeKB.com" <u31540@uwe> said:
here is what i have:

a sheet titled "new labels" and a sheet titled "builder" a checkbox on the
sheet builder is supposed to fire the macro:

Sub six_panel()
Application.ScreenUpdating = False
If ("basedooranswer") = "FLUSH HOLLOW CORE" Then
Selection.Goto reference:=("onepa_ilo_fhc")
Selection.EntireRow.Hidden = False
End If
Application.Goto reference:="six_panel"
Selection.EntireRow.Hidden = False
Sheets("builder").Select
Application.ScreenUpdating = True
End Sub

The second part of it works just fine, however it doesnt complete the first
part. "onepa_ilo_fhc" is a row on the sheet "new labels". if more info is
needed i can provide. thanks,



JE said:
What does "doesnt it work" mean to you?

If

(a) there's a workbook-level named range "onepa_ilo_fhc", or if the
named range is a worksheet-level named range and that worksheet is
active, and

(b) the variable basedooranswer = "FLUSH HOLLOW CORE"

then after the code is run, the sheet containing the referenced range
"onepa_ilo_fhc" should be active and the row(s) referenced by
"onepa_ilo_fhc" should be visible.

Works on a test workbook for me.

However, there are any number of other things that could "not work",
depending on the "other code" and a host of other factors...
this is my code inside of some other code.
[quoted text clipped - 5 lines]
why doesnt it work?
thanks
 
B

brownti via OfficeKB.com

its a labeled cell



JE said:
The text string

"basedooranswer"

(which is NOT a variable) will never equal

"FLUSH HOLLOW CORE"

so the If...Then branch will never be taken.

So fixing it depends on what basedooranswer is supposed to be.

If it's supposed to be a global or module-level variable then you need
to take it out of quotes.
here is what i have:
[quoted text clipped - 41 lines]
 
J

JE McGimpsey

Not sure what help you need -

I pointed out that your code uses "basedooranswer" as a string literal.
If it's supposed to be a labeled cell, then you need to use it as the
reference to a range. For instance, instead of

If ("basedooranswer") = "FLUSH HOLLOW CORE" Then

it should be

If ActiveSheet.Range("basedooranswer").Text = _
"FLUSH HOLLOW CORE" Then

or perhaps:

If ActiveWorkbook.Names("basedooranswer").RefersToRange.Text = _
"FLUSH HOLLOW CORE"
 
B

brownti via OfficeKB.com

I just still can't get it to work. Here is the code:

Sub six_panel()
Application.ScreenUpdating = False
If ActiveSheet.Range("basedooranswer").Text = "FLUSH HOLLOW CORE" Then
Sheets("new labels").Select
Application.Goto reference:="onepa_ilo_fhc"
Selection.EntireRow.Hidden = False
End If
Application.Goto reference:="six_panel"
Selection.EntireRow.Hidden = False
Sheets("builder").Select
Application.ScreenUpdating = True
End Sub

When i run the macro everything under the End If works, however the If
statement does not work. I will also be the first to admit I dont know very
much about macros and the code that goes into them. I know what i have
gotten to work in the past and just try to minupulate that code to make it
work in a different context. I also really appreciate all the help I have
been getting. Thanks,
 
J

JE McGimpsey

If the "If" statement doesn't work, what is in the cell labelled
"basedooranswer"?

Is the sheet that contains "basedooranswer" the active sheet?

Try stepping through the code one line at a time (F8) - what is the
value of ActiveSheet.Range("basedooranswer").Text?
 
B

brownti via OfficeKB.com

i think the problem is related to the basedooranswer not being correct. when
i step through it, it goes to the if statement and then skips over the then
part, probably because it thinks the if statement isnt true. the cell
labeled "basedooranswer" is filled with the answer to an inputbox:

Dim myinput As String
myinput = LCase(InputBox("What slab for base price?"))
Range("basedooranswer").Value = UCase(myinput)
If myinput = "6 panel" Then.......

One thing that i noticed is that when i have basedooranswer selected, it says
it as its name in the upper left corner, but when i define name it is
FLUSH_HOLLOW_CORE which is what is entered in the cell. It doesnt seem to
matter what i try, i just cant get it to work out...


JE said:
If the "If" statement doesn't work, what is in the cell labelled
"basedooranswer"?

Is the sheet that contains "basedooranswer" the active sheet?

Try stepping through the code one line at a time (F8) - what is the
value of ActiveSheet.Range("basedooranswer").Text?
I just still can't get it to work. Here is the code:
[quoted text clipped - 13 lines]
When i run the macro everything under the End If works, however the If
statement does not work.
 
Top