Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default can't create excel add-in macro to use with other workbooks

I have copied my code below. But to create the add-in, I opened a new
workbook, opened VBA, copied the code into a new module. Went back to the
workbook, gave it a tile in the properties under file. Tested the code on
this workbook and then saved it as an *.xla file. I have had two things
happen:

1)either when I select the add-in the workbook I am looking at will freeze
and I won't be able to select any cells, although I can do everything else,
ie use the file menus, look at vba etc.

2) when I have gotten the add-in to seem to install correctly and it shows
up in vba but not as a workbook, the macro does not show up in the list of
macros on any workbook.

Can someone help? Thanks


'Programmer: Tscharner Upjohn
'Date: 2/20/07
'Purpose: Copy average capital from an excel sheet 1 brought in from a
performance report in advent
' to sheet 2 matching the account codes and putting average capital values
next to them

Public Sub getAvgCapital()
'Declaration
Dim acctIndex1, acctIndex2, avgCapIndex, firstARow, firstKRow,
firstSRow, blanks As Integer
Dim acct As String
Dim endFile As Boolean

'Initialization
acctIndex1 = 1
blanks = 0
endFile = False
acct = ActiveWindow.RangeSelection.Cells(1, 1).Value

'Count number of rows in sheet1 finding the first account that starts
with a (firstARow)
'k (firstKRow) and with s (firstSRow)
Do While firstSRow = 0
numRows1 = numRows1 + 1
temp = Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("A"
& numRows1).Value
If Len(temp) = 8 Then
Select Case Left(temp, 1)
Case "a", "A"
If (firstARow = 0) Then
firstARow = numRows1
End If
Case "k", "K"
If (firstKRow = 0) Then
firstKRow = numRows1
End If
Case "s", "S"
If (firstSRow = 0) Then
firstSRow = numRows1
End If
End Select
End If
Loop
Do While acct < ""
Select Case Left(acct, 1)
Case 0 To 9
acctIndex2 = 1
Case "a" To "j", "A" To "J"
acctIndex2 = firstARow
Case "k" To "r", "K" To "R"
acctIndex2 = firstKRow
Case Else
acctIndex2 = firstSRow
End Select
Do While endFile < True
If (Workbooks("iccallAvgCap.xls").Worksheets("sheet1" ).Range("A"
& acctIndex2).Value = acct) Then
avgCapIndex = acctIndex2 + 1
Do While
Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("A" &
avgCapIndex).Value < "Average Capital"
avgCapIndex = avgCapIndex + 1
Loop
ActiveWindow.RangeSelection.Cells(acctIndex1, 2).Value =
Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("B" &
avgCapIndex).Value
endFile = True
End If
acctIndex2 = acctIndex2 + 1
Loop

acctIndex1 = acctIndex1 + 1
acct = ActiveWindow.RangeSelection.Cells(acctIndex1, 1).Value
endFile = False
Loop
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default can't create excel add-in macro to use with other workbooks

macros in an addin do not show up in the Tools=Macro=Macros list. this is
expected behavior.

--
Regards,
Tom Ogilvy


"icccapital" wrote:

I have copied my code below. But to create the add-in, I opened a new
workbook, opened VBA, copied the code into a new module. Went back to the
workbook, gave it a tile in the properties under file. Tested the code on
this workbook and then saved it as an *.xla file. I have had two things
happen:

1)either when I select the add-in the workbook I am looking at will freeze
and I won't be able to select any cells, although I can do everything else,
ie use the file menus, look at vba etc.

2) when I have gotten the add-in to seem to install correctly and it shows
up in vba but not as a workbook, the macro does not show up in the list of
macros on any workbook.

Can someone help? Thanks


'Programmer: Tscharner Upjohn
'Date: 2/20/07
'Purpose: Copy average capital from an excel sheet 1 brought in from a
performance report in advent
' to sheet 2 matching the account codes and putting average capital values
next to them

Public Sub getAvgCapital()
'Declaration
Dim acctIndex1, acctIndex2, avgCapIndex, firstARow, firstKRow,
firstSRow, blanks As Integer
Dim acct As String
Dim endFile As Boolean

'Initialization
acctIndex1 = 1
blanks = 0
endFile = False
acct = ActiveWindow.RangeSelection.Cells(1, 1).Value

'Count number of rows in sheet1 finding the first account that starts
with a (firstARow)
'k (firstKRow) and with s (firstSRow)
Do While firstSRow = 0
numRows1 = numRows1 + 1
temp = Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("A"
& numRows1).Value
If Len(temp) = 8 Then
Select Case Left(temp, 1)
Case "a", "A"
If (firstARow = 0) Then
firstARow = numRows1
End If
Case "k", "K"
If (firstKRow = 0) Then
firstKRow = numRows1
End If
Case "s", "S"
If (firstSRow = 0) Then
firstSRow = numRows1
End If
End Select
End If
Loop
Do While acct < ""
Select Case Left(acct, 1)
Case 0 To 9
acctIndex2 = 1
Case "a" To "j", "A" To "J"
acctIndex2 = firstARow
Case "k" To "r", "K" To "R"
acctIndex2 = firstKRow
Case Else
acctIndex2 = firstSRow
End Select
Do While endFile < True
If (Workbooks("iccallAvgCap.xls").Worksheets("sheet1" ).Range("A"
& acctIndex2).Value = acct) Then
avgCapIndex = acctIndex2 + 1
Do While
Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("A" &
avgCapIndex).Value < "Average Capital"
avgCapIndex = avgCapIndex + 1
Loop
ActiveWindow.RangeSelection.Cells(acctIndex1, 2).Value =
Workbooks("iccallAvgCap.xls").Worksheets("sheet1") .Range("B" &
avgCapIndex).Value
endFile = True
End If
acctIndex2 = acctIndex2 + 1
Loop

acctIndex1 = acctIndex1 + 1
acct = ActiveWindow.RangeSelection.Cells(acctIndex1, 1).Value
endFile = False
Loop
End Sub



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
Create a macro to create excel line graph with coloured pointers anddata lables anuj datta Charts and Charting in Excel 1 September 30th 09 04:04 PM
I can not create an external link between two Excel 2007 workbooks Bill R Excel Worksheet Functions 1 August 27th 09 04:12 PM
create a macro that compares two workbooks blopreste3180 Excel Discussion (Misc queries) 2 September 5th 07 05:26 PM
Create multiple workbooks from a single Excel spreadsheet slowjam4 Excel Programming 2 December 11th 06 01:10 PM
Macro to create workbooks and pivot tables Ciara Excel Programming 2 September 19th 06 10:20 AM


All times are GMT +1. The time now is 01:51 AM.

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

About Us

"It's about Microsoft Excel"