We help IT Professionals succeed at work.
Get Started

VBA: Problem Posting Transposed Array to Range

bishop3000
bishop3000 asked
on
1,741 Views
Last Modified: 2008-09-12
Hi,
In the attached code, I get Run-Time Error 13 (type mismatch) when trying to post a transposed array to a vertical range. The problematic line is indicated in the code.
What am I doing wrong?
Thanks!
-Michael


Sub ImportFromCustomerDatabase()
 
Dim Inputs As Worksheet, Settings As Worksheet, CellRefNames As Worksheet
Dim DatabaseName As String, Folder As String, FirstRow As Integer
Dim Data_Values As Worksheet, Data_Formulas As Worksheet, SaveHistory As Worksheet
Dim CustomerCount As Integer, CustomerRow As Integer, ColumnsCount As Integer
Dim CurrentNamesColumn, StorageColumn As Integer, StartRow As Integer, EndRow As Integer
Dim StorageArray()
 
Set Inputs = Sheets("Inputs")
Set Settings = Sheets("Settings & Support")
Set CellRefNames = Sheets("CellRefNames")
 
' Step 1: Store the Inputs page info for undo
 
Application.ScreenUpdating = False
 
CurrentNamesColumn = CellRefNames.Rows(8).Find("CustData--CurrentNames").Column
StorageColumn = CellRefNames.Rows(8).Find("CustData--Storage").Column
StartRow = CellRefNames.Columns(1).Find("RefNamesStart").Row + 1
EndRow = CellRefNames.Columns(1).Find("RefNamesEnd").Row - 1
 
ReDim StorageArray(1 To EndRow - StartRow + 30)
 
For i = StartRow To EndRow
If CellRefNames.Cells(i, CurrentNamesColumn) <> "" Then
  StorageArray(i - StartRow + 1) =  _
  Range(CellRefNames.Cells(i,  CurrentNamesColumn).Value).Formula
  Else: StorageArray(i - StartRow + 1) = ""
End If: Next i
 
With CellRefNames: .Range(.Cells(StartRow, StorageColumn), .Cells(EndRow, _ StorageColumn)).Value = Application.Transpose(StorageArray): End With   
' Returns 'Type Mismatch error
 
Application.ScreenUpdating = True
 
End Sub

Open in new window

Comment
Watch Question
Mechanical Engineer
CERTIFIED EXPERT
Most Valuable Expert 2013
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE