Senin, 08 Oktober 2012

Re: [ExcelVBA] Abbreviations to Words

 

Derek,

Collections - again!

I can't get your statement
Cells(nRow, nFullNameColumn).Value = clxFruit.Item("key" & Cells(nRow, nAbbreviatedNameColumn).Value)

to work. 

Here is my code

Sub Main()

Dim clxFruit As New Collection
Dim shtSht1
Dim nF
Dim nA
Dim nrow As Integer
Set shtSht1 = Sheets("Sheet1")

clxFruit.Add shtSht1.Range("B2"), "key" & shtSht1.Range("A2")
clxFruit.Add shtSht1.Range("B3"), "key" & shtSht1.Range("A3")
clxFruit.Add shtSht1.Range("B4"), "key" & shtSht1.Range("A4")
Debug.Print clxFruit.Count
Debug.Print clxFruit.Item(2)
nF = Range("Fruit")
nA = Range("Abb")
nrow = 3
Cells(nrow, nF).Value = clxFruit.Item("key" & Cells(nrow, nA).Value)

A2 to A4 contain abbreviations, and B2 to B4 contain names. The 2 Debug.Print statements show that the assignments worked.
Abb is the name I gave to a column of abbreviation, and Fruit the name of the cells which I want to contain the names. I think my last statement is an accurate implementation of your statement, but when I execute it I get a "Run-time error '13', Type mismatch.

What did I do wrong?

Thanks,
Mickey

[Non-text portions of this message have been removed]

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (9)
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
.

__,_._,___

Tidak ada komentar:

Posting Komentar