Solved

Explanation of VB Code in Excel spreadsheet

Posted on 2014-09-03
4
145 Views
Last Modified: 2014-09-04
Experts,

I had this code in an Excel spreadsheet to delete rows that had values < 0.  I want to use this logic again, but I am not sure  what this statement means.

It is  Cells(i + 3, j * 3 + 1)  that I need an explanation of

            If Cells(i + 3, j * 3 + 1) <> 0 And Len(Cells(i + 3, j * 3 + 1)) > 0 Then GoTo notDelete
0
Comment
Question by:morinia
  • 2
4 Comments
 
LVL 32

Assisted Solution

by:Rob Henson
Rob Henson earned 250 total points
ID: 40301145
This uses the Cells function to identify the cell reference, it uses the following syntax:

Cells(Row,Column) where Row and Column are integers representing row and column numbers.

Your code has the Row and Column numbers set by variables i and j, these will have been set to a value earlier in the code.

Thanks
Rob H
0
 
LVL 46

Accepted Solution

by:
Martin Liss earned 250 total points
ID: 40301154
The Cells() function is Cells(Row number, Column number)

i + 3 is a variable named "i" incremented by 3 and it is the row number
j * 3 + 1 is another variable named "j" multiplied by 3 before adding 1 and used as the column number
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40301254
I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 40303100
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now