LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to modify VBA code for Add-in?

Shetty,

I would suggest that you start by putting the code in another workbook, and
run it from there. You should be able to find most of the problems.

As a starter, remove all select statements and make it more generic. Here is
a quick recut (not tested, so you should check out it still works, there is
probably some lost reference to an activesheet that you should restore by
object variables)

Call Manual_Calc
'+++++++++ TIMER START
myTime(1) = timeGetTime()
'+++++++ Check for any existing sheet and then replace with new.
Application.DisplayAlerts = False
For Each sh In ThisWorkbook.Worksheets
If ((sh.Name = "TEMP") Or (sh.Name = "Report")) Then
sh.Delete
End If
Next
Application.DisplayAlerts = True
Worksheets.Add.Name = "Report"
'+++++++ IN
Set Sht1 = Sheets("In")
Set Sht2 = Sheets("Report")
Set Sht3 = Worksheets.Add.Name = "TEMP"
Sht2.Cells.Clear
Sht1.Select
Ref1 = 10
Sht1.Cells(1, 1).AutoFilter Ref1, Ref2
Sht1.Cells(1, 1).CurrentRegion.Copy Sht3.Cells(1, 1)
Sht1.AutoFilterMode = False
Sht3.Activate
Range("A:A,E:E,D:D,J:J,K:K,L:L,M:M,N:N").Copy
Sheets("Report").Select
Range("A1").PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Columns("A:A").NumberFormat = "dd-mmm-yy"
Application.CutCopyMode = False
Sht3.Delete
Columns("H:H").Insert Shift:=xlToRight
Range("H1").Value = "Type"
With Range("H2")
Do While IsEmpty(.Offset(i, -1)) = False
.Offset(i, 0).FormulaR1C1 = "Receipt"
i = i + 1
Loop
End With
Set Sht1 = Nothing
Set Sht2 = Nothing
Set Sht3 = Nothing
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Shetty" wrote in message
m...
I am creating an add-in for excel which creats a new sheet with data
based on the existing sheets(4 sheets) and a temp sheet which is
deleted at the end.

The primary reason is that I dont want user to run the macro at wrong
place which will mess up the whole data sheets. So I need to create
the new workbook called Reportbook.xls and create the report sheet
there with opening the original workbook as read only. My existing
code runs perfectly within the data workbook. I need to know how to
modify the various componants of code and user forms so that it works
in the addin.



 
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
Modify code bigmaas Excel Discussion (Misc queries) 2 February 16th 10 10:51 AM
modify a line code TUNGANA KURMA RAJU Excel Discussion (Misc queries) 6 June 3rd 08 12:31 PM
Modify Code Richard Excel Worksheet Functions 0 March 13th 08 08:19 PM
Modify duplicate code Michael[_26_] Excel Programming 0 January 7th 04 03:00 PM
Modify Find Code Al[_6_] Excel Programming 1 July 15th 03 10:35 PM


All times are GMT +1. The time now is 08:32 AM.

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"