PDA

View Full Version : VBA Scripting question...


giena
11-08-2008, 02:17 PM
Okay, so I'm taking a programming course that uses VBA.

I'm having an issue trying to figure out how to display my data in an excel workbook.

We have to take a starting number and an ending number, then determine their square roots and cube roots. Then, we need to display them in a very specific manner in a workbook. Our starting and ending numbers are generated from user input, so the range can be 3 numbers or 1000, it's totally up to the user.

I get the math part, thats easy enough. But I don't quite understand how to display the data once the computations are complete.

I understand that you can use this:

Cells(1, 1).Value = "Math Table"
Cells(3, 1).Value = "Number"
Cells(3, 3).Value = "Square"
Cells(3, 5).Value = "Cube"

to display those values in the specified fields. But how do I address actually displaying the squares and cubes under the appropriate columns and rows? Would it use a rowcount + 1 type of argument?

Filatal
11-09-2008, 09:25 AM
I'm really rusty with VB, but I'm thinking Cell.Offset(x,y) might be what you need, trying looking up its usage.

giena
11-09-2008, 04:47 PM
Thanks Filatal, will check it out.

Cloudwalker21
11-10-2008, 12:36 AM
thats a really bass ackwards set of cells for those things, if I'm understanding it right. I'd say trying using a loop that goes through number by number with a 1 to N counter, and for each one, do the computations and save em. Then for determining where to put each computation (and the number value itself), you'd have to offset it based off of that 1 to N counter you're using.