Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default A begginer trying to use arrays

If you were to call me a begginner you'd be over doing it. :D


Here's what I'm trying to pull of.


I have assigned book marks, in this case A, AA, AAA, then in another
cell the user will type in the names of the bookmarks
"A, AA, AAA". From there I need to cyle threw whatever bookmarks the
user has typed in and sum up 4 numbers that are placed relative to each

bookmarked cell, and print the result from each bookmark sum in another

cell.


I'm pretty darn lost...please showme the light! Thanks.


--------------------------


Option Explicit


Sub test()


Dim i As Integer


Dim valueme() As String
valueme = Split([c60], ",")


'C60 = "A, AA, AAA" - my bookmark names


For i = 0 To UBound(valueme)
valueme(i) = Trim(valueme(i))


Next i


End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default A begginer trying to use arrays

Bookmarks = range names???

First, I think you'd have to a little checking in those cells to make sure that
the user entered the valid range names, too:

Option Explicit
Sub test()

Dim i As Long
Dim TestRng As Range
Dim ValueMe As Variant
Dim myCell As Range
Dim myRng As Range
Dim mySum As Double

With ActiveSheet
Set myRng = .Range("C60:c65")
For Each myCell In myRng.Cells
mySum = 0
ValueMe = Split(myCell.Value, ",")
For i = LBound(ValueMe) To UBound(ValueMe)
Set TestRng = Nothing
On Error Resume Next
Set TestRng _
= ThisWorkbook.Names(Trim(ValueMe(i))).RefersToRange
On Error GoTo 0

If TestRng Is Nothing Then
'not a valid entry, just skip it???
Else
mySum = mySum + Application.Sum(TestRng)
End If
Next i
myCell.Offset(0, 1).Value = mySum
Next myCell
End With
End Sub

If there is an error, you may want:

If TestRng Is Nothing Then
mySum = CVErr(xlErrRef)
Exit For
Else
mySum = mySum + Application.Sum(TestRng)
End If

Just to show that it should be cleaned up before you can trust the results.



wrote:

If you were to call me a begginner you'd be over doing it. :D

Here's what I'm trying to pull of.

I have assigned book marks, in this case A, AA, AAA, then in another
cell the user will type in the names of the bookmarks
"A, AA, AAA". From there I need to cyle threw whatever bookmarks the
user has typed in and sum up 4 numbers that are placed relative to each

bookmarked cell, and print the result from each bookmark sum in another

cell.

I'm pretty darn lost...please showme the light! Thanks.

--------------------------

Option Explicit

Sub test()

Dim i As Integer

Dim valueme() As String
valueme = Split([c60], ",")

'C60 = "A, AA, AAA" - my bookmark names

For i = 0 To UBound(valueme)
valueme(i) = Trim(valueme(i))

Next i

End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default A begginer trying to use arrays

Thanks, I'll be using bits and peaces of your code. I'm flying now!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use of arrays DKS Excel Worksheet Functions 1 November 30th 06 08:38 PM
Arrays Tobro88 Excel Discussion (Misc queries) 3 November 18th 05 11:28 PM
Begginer Help viralbhatt Excel Discussion (Misc queries) 3 August 23rd 05 10:36 AM
VBA arrays hokiebird Excel Programming 3 November 11th 04 10:38 AM
VBA for Excel Begginer darkeh[_2_] Excel Programming 2 October 21st 04 03:34 PM


All times are GMT +1. The time now is 02:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"