ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Making a C++ like if statment case for excel in VBA (https://www.excelbanter.com/excel-programming/337411-making-c-like-if-statment-case-excel-vba.html)

Jimmy Hoffa

Making a C++ like if statment case for excel in VBA
 
i need to have code line look at a cell, say L20, which is a drop box
(yes/no). If the box says yes it then needs to remove the user data from
cells N20-T20. If it says no, it does nothing. I know that im gonna have a
if/then/else/end if statement. but i havent written in VBA in years, and im
quite rusty since im used to Java at this point. Also this needs to be for a
500 cell deep spreadsheet. I wasnt to fond of the idea of making 499
different statments for this, but i can understand if thats the only way.
Someone please help me with this, since i dont want to do this in Java and
integrate into a excel sheet, when im not the primary user.


Dick Kusleika[_4_]

Making a C++ like if statment case for excel in VBA
 
Jimmy, where've you been?

Try something like this:

Dim rCell as Range
Dim rRng as Range

Set rRng = Sheet1.Range("L20:L519")

For Each rCell in rRng.Cells
If rCell.Value = "yes" Then
rCell.Offset(0,2).Resize(1,7).ClearContents
End If
Next rCell


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

Jimmy Hoffa wrote:
i need to have code line look at a cell, say L20, which is a drop box
(yes/no). If the box says yes it then needs to remove the user data
from cells N20-T20. If it says no, it does nothing. I know that im
gonna have a if/then/else/end if statement. but i havent written in
VBA in years, and im quite rusty since im used to Java at this point.
Also this needs to be for a 500 cell deep spreadsheet. I wasnt to
fond of the idea of making 499 different statments for this, but i
can understand if thats the only way. Someone please help me with
this, since i dont want to do this in Java and integrate into a excel
sheet, when im not the primary user.





All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com