vba problem

stilgar

Board Regular
Joined
Feb 28, 2011
Messages
51
i've got a sheet that i've wrote a heap of code for but i'm stuck on a section of it. please note i'm only new to vba :)

i've got data in cells d27 and d30 that gets entered in by a macro when a button is clicked.

this makes cell d33 display text when either of those 2 cells are populated

what i want is code so when cell d27 and d30 have nothing displayed in them then cell d33 will display nothing aswell

hope i explained that well enough
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Code:
@if(and(isblank(d30),isblank(d27)),"","your_text")
 
Upvote 0
thanks but i'm not sure i understand.

is this to be used in vb? it looks like a formula is all
 
Upvote 0
Yes, it's formula. You need checking in VBA? IMHO, formula is easiest way to handle this. :)
 
Upvote 0
i've got a sheet that i've wrote a heap of code for but i'm stuck on a section of it. please note i'm only new to vba :)

i've got data in cells d27 and d30 that gets entered in by a macro when a button is clicked.

this makes cell d33 display text when either of those 2 cells are populated

what i want is code so when cell d27 and d30 have nothing displayed in them then cell d33 will display nothing aswell

hope i explained that well enough


Do you mean something like this?

If Range("D27").Value = "" and Range("D30").Value = "" Then Range("D33").Value = ""
 
Upvote 0
yeah thats great thanks! how do i have it so that it runs constantly though?
 
Last edited:
Upvote 0
Hi,

You need a loop. Now of course what are you looping (specific ranges, columns, etc.) So it always going to be row 27 and 30, but different columns?

abousetta
 
Upvote 0
Stilgar
Maybe you could post your code and one of us can show you where to place the line John has provided.
 
Upvote 0
ok well the code that runs in that cell is:

Sub Calculatefaceplate()
Dim sPartial As String
Dim sDuctPartNumber As String
Dim sCell As String

sDuctPartNumber = "PL"

Select Case Range("B7").Value
Case "35mm x 125mm Skirting Duct": sPartial = "125": sCell = "D33"
Case "35mm x 150mm Skirting Duct": sPartial = "150": sCell = "D33"
Case "50mm x 150mm Skirting Duct": sPartial = "150": sCell = "D33"
Case "50mm x 200mm Skirting Duct": sPartial = "200": sCell = "D33"
Case Else: sPartial = "XXXXX": MsgBox "Invalid dimensions face 1": GoTo End_Sub
End Select

sDuctPartNumber = sDuctPartNumber & sPartial

Select Case Range("b21").Value
Case "DROP-IN LID SELECTED": sPartial = "DFC": sCell = "D33"
Case "CLIP-ON LID SELECTED": sPartial = "CFC": sCell = "D33"
Case Else: sPartial = "XXXXX": MsgBox "Invalid dimensions face 2": GoTo End_Sub
End Select

sDuctPartNumber = sDuctPartNumber & sPartial


Select Case Range("B18").Value
Case "BLACK": sPartial = "B"
Case "WHITE": sPartial = "W"
Case "OPAL GREY": sPartial = "O"
Case "NATURAL ANODISED": sPartial = "N"
Case "POWDERCOATED": sPartial = "S"
Case Else: sPartial = "X": MsgBox "Invalid color": GoTo End_Sub
End Select
sDuctPartNumber = sDuctPartNumber & sPartial

If InStr(sDuctPartNumber, "X") > 0 Then sDuctPartNumber = ""

Range(sCell) = sDuctPartNumber
End_Sub:
End Sub


i've used jons code in a seperate sub but i have to run it using a control button. so i have to click it to update everytime

really the sheet is at the stage where if i could make a new sub that runs cirtian macro's depending on what conditions are met then that should solve it. this macro would need to run in a loop though.

the sheets uses some drop down menu's and others are run when a control button is clicked. eg: "would you require this part?" click yes or no and the cell displays the correct part number

i'm still new to vb so slowly learning
 
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

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