Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cant Fill Array 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
I have created the following array:

Code:
Dim LR As Long
Dim Fib1 As Double
Dim myarray As Variant
Dim H2 as Double

LR = ActiveSheet.UsedRange.Rows.Count

myarray = Range("G2:G & LR").Value

if H2 >0 than
'Looping structure to look at array.
 For Fib1 = 1 To UBound(myarray)
 MsgBox myarray(Fib1, 1)

Next

Next

I get the error myarray is empty

What I'm trying to do is look at all the data in column G

Some cells in this range are blank
if data exists assign each value to the array H2
H2(1) would be first value
H2(2) would be second value so on and so on

Any help would be greatly appreciated
 
to JTBorton:

If you think my sketches are good you should see my daughter's. She's in first grade and she can use colors too! [lol]


to vba317:
Umm?? OK??

I guess you're welcomed? But, you already had a chunk of it done. You just couldn't figure out a way to record the number after it was found for later processing.

All I did was create a variable for storing the number(s). This is why commenting your code is helpful/necessary--to help you figure out the logic you wish to pursue.


I couldn't stand the duplicated validation code: your 'if LOWx/HIGHx then'. They just needed to be combined because you are making the computer work harder (and hotter) by having to validate the same cell twice. . . once for 'copy to G/H' and again just to 'color the cell'.

Just have it do the validation once, then do all the stuff it needs to do THERE, before going on to the next set of instructions.

Don't forget to comment/remark your code, it'll be easier for everyone involved.

--MiggyD

My mind not only wanders, it sometimes leaves completely.
 
I know it's been awhile, but I have been using MiggyD's code. I am noticing that the output calculations are being put in the wrong spot and also the total calculations are using the wrong values. Is there a simple way to change the formulas that the values that are being calculated from, so I can see the error of my ways? I tried to change the MarkedGreen = Range("C" & R1) into Range("C" & R1 + 1).Formula and I got an invalid use of property error message. Any help would be appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top