Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Place code in a new workbook with a macro.

First, I just want to say thanks to all the people contributin
knowlledge in this forum. It has been a weath of information for m
over the past few days. Now my question.


I have created a macro wich I have saved as an add-in in order t
distribute. This macro creates a combo box on seperate workbook an
populates it with data from the saved .xla. It also has a linke
cell on the new workbook.

My problem is that when the value in the combo box and linked cel
changes I would like another cell's value to change.

I have tried to do this with If / Then statements but of course thos
statements only get run once when the macro runs.

Idealy I would like the If / Then statements to be placed under
Private Sub ComboBox1_Change() in the new workbook. My problem her
is that the workbook is overwritten everytime I run the reporting ap
that creates the new workbook. (the reason I saved this macro as a
add-in in the first place.)

Is there anyway to do what I am attempting ??

This is the code I have in the .xla so far. Mostly thanks to yo
guys.


Columns("A:A").ColumnWidth = 16
Columns("B:B").ColumnWidth = 30
Columns("C:C").ColumnWidth = 18
Columns("B:B").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1"
Link:=False, _
DisplayAsIcon:=False, Left:=395.25, Top:=11.8, Width:=96
Height:=27.75 _
).Select

ActiveSheet.Shapes("ComboBox1").Select
Selection.ShapeRange.ScaleWidth 1.01, msoFalse
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse
msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.02, msoFalse
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1.2, msoFalse
msoScaleFromTopLeft

ThisWorkbook.Sheets("Sheet2").Range("b1").Value = "William Day"

ThisWorkbook.Sheets("Sheet2").Range("b2").Value = "Michael Becker"

ThisWorkbook.Sheets("Sheet2").Range("b3").Value = "Jason Craig"

ThisWorkbook.Sheets("Sheet2").Range("b4").Value = "Saeed Mirza"

ThisWorkbook.Sheets("Sheet2").Range("b5").Value = "Chris Webber"

ThisWorkbook.Sheets("Sheet2").Range("b6").Value = "Matthew Gray"

ThisWorkbook.Sheets("Sheet2").Range("b7").Value = "James Pence"

ThisWorkbook.Sheets("Sheet2").Range("b8").Value = "Chuc
Patenaude"

ThisWorkbook.Sheets("Sheet2").Range("b9").Value = "Jimmy Zheng"

ThisWorkbook.Sheets("Sheet2").Range("b10").Value = "Armando Ruiz"

ActiveSheet.ComboBox1.ListFillRange
"[ColWidAlgnTextTest.xla]Sheet2!b1:b10"
ActiveSheet.ComboBox1.LinkedCell = "e2"

If ActiveSheet.Range("e2").Value = "William Day" Then
ActiveSheet.Range("f2").Value = "DAYWI"
End If
If ActiveSheet.Range("e2").Value = "Michael Becker" Then
ActiveSheet.Range("f2").Value = "BECKERMI"
End If
If ActiveSheet.Range("e2").Value = "Jason Craig" Then
ActiveSheet.Range("f2").Value = "CRAIGJA"
End If
If ActiveSheet.Range("e2").Value = "Saeed Mirza" Then
ActiveSheet.Range("f2").Value = "MIRZASA"
End If
If ActiveSheet.Range("e2").Value = "Chris Webber" Then
ActiveSheet.Range("f2").Value = "WEBBERCH"
End If

ActiveSheet.Range("g6").Formula = "=COUNTIF(a1:a5000,f2)"
ActiveSheet.Range("g7").Formula = "=COUNTIF(a1:a5000,e2)"
ActiveSheet.Range("g9").Formula = "=SUM(g6:g7)"

Columns("G:G").ColumnWidth = 3.43

ActiveSheet.Range("h6").Value = "HD & CHG Tickets"
ActiveSheet.Range("h7").Value = "TSK Tickets"
ActiveSheet.Range("h9").Value = "Total Tickets Resolved"
Columns("H:H").EntireColumn.AutoFit

ActiveSheet.Range("a1").Selec

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Place code in a new workbook with a macro.

Hi
not quite sure but maybe the following site will help you:
http://www.cpearson.com/excel/vbe.htm

--
Regards
Frank Kabel
Frankfurt, Germany


First, I just want to say thanks to all the people contributing
knowlledge in this forum. It has been a weath of information for me
over the past few days. Now my question.


I have created a macro wich I have saved as an add-in in order to
distribute. This macro creates a combo box on seperate workbook and
populates it with data from the saved .xla. It also has a linked
cell on the new workbook.

My problem is that when the value in the combo box and linked cell
changes I would like another cell's value to change.

I have tried to do this with If / Then statements but of course those
statements only get run once when the macro runs.

Idealy I would like the If / Then statements to be placed under
Private Sub ComboBox1_Change() in the new workbook. My problem
here is that the workbook is overwritten everytime I run the
reporting app that creates the new workbook. (the reason I saved this
macro as an add-in in the first place.)

Is there anyway to do what I am attempting ??

This is the code I have in the .xla so far. Mostly thanks to you
guys.


Columns("A:A").ColumnWidth = 16
Columns("B:B").ColumnWidth = 30
Columns("C:C").ColumnWidth = 18
Columns("B:B").Select
With Selection
HorizontalAlignment = xlCenter
VerticalAlignment = xlBottom
WrapText = False
Orientation = 0
AddIndent = False
ShrinkToFit = False
MergeCells = False
End With

ActiveSheet.OLEObjects.Add(ClassType:="Forms.Combo Box.1",
Link:=False, _
DisplayAsIcon:=False, Left:=395.25, Top:=11.8, Width:=96,
Height:=27.75 _
).Select

ActiveSheet.Shapes("ComboBox1").Select
Selection.ShapeRange.ScaleWidth 1.01, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 0.5, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleWidth 1.02, msoFalse,
msoScaleFromTopLeft
Selection.ShapeRange.ScaleHeight 1.2, msoFalse,
msoScaleFromTopLeft

ThisWorkbook.Sheets("Sheet2").Range("b1").Value = "William Day"

ThisWorkbook.Sheets("Sheet2").Range("b2").Value = "Michael Becker"

ThisWorkbook.Sheets("Sheet2").Range("b3").Value = "Jason Craig"

ThisWorkbook.Sheets("Sheet2").Range("b4").Value = "Saeed Mirza"

ThisWorkbook.Sheets("Sheet2").Range("b5").Value = "Chris Webber"

ThisWorkbook.Sheets("Sheet2").Range("b6").Value = "Matthew Gray"

ThisWorkbook.Sheets("Sheet2").Range("b7").Value = "James Pence"

ThisWorkbook.Sheets("Sheet2").Range("b8").Value = "Chuck
Patenaude"

ThisWorkbook.Sheets("Sheet2").Range("b9").Value = "Jimmy Zheng"

ThisWorkbook.Sheets("Sheet2").Range("b10").Value = "Armando Ruiz"

ActiveSheet.ComboBox1.ListFillRange =
"[ColWidAlgnTextTest.xla]Sheet2!b1:b10"
ActiveSheet.ComboBox1.LinkedCell = "e2"

If ActiveSheet.Range("e2").Value = "William Day" Then
ActiveSheet.Range("f2").Value = "DAYWI"
End If
If ActiveSheet.Range("e2").Value = "Michael Becker" Then
ActiveSheet.Range("f2").Value = "BECKERMI"
End If
If ActiveSheet.Range("e2").Value = "Jason Craig" Then
ActiveSheet.Range("f2").Value = "CRAIGJA"
End If
If ActiveSheet.Range("e2").Value = "Saeed Mirza" Then
ActiveSheet.Range("f2").Value = "MIRZASA"
End If
If ActiveSheet.Range("e2").Value = "Chris Webber" Then
ActiveSheet.Range("f2").Value = "WEBBERCH"
End If

ActiveSheet.Range("g6").Formula = "=COUNTIF(a1:a5000,f2)"
ActiveSheet.Range("g7").Formula = "=COUNTIF(a1:a5000,e2)"
ActiveSheet.Range("g9").Formula = "=SUM(g6:g7)"

Columns("G:G").ColumnWidth = 3.43

ActiveSheet.Range("h6").Value = "HD & CHG Tickets"
ActiveSheet.Range("h7").Value = "TSK Tickets"
ActiveSheet.Range("h9").Value = "Total Tickets Resolved"
Columns("H:H").EntireColumn.AutoFit

ActiveSheet.Range("a1").Select


---
Message posted from http://www.ExcelForum.com/


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
Where 2 place the code? (Worksheet Codes Vs. Modules) FARAZ QURESHI Excel Discussion (Misc queries) 3 February 23rd 09 02:01 AM
How to code VBA: Auto open workbook and run macro March Excel Discussion (Misc queries) 4 November 8th 07 08:25 PM
VBA Code to kick off macro when workbook command to close is initi zulfer7 Excel Discussion (Misc queries) 2 June 23rd 06 08:04 PM
VBA Code To have a macro repeat on all sheets in a workbook carl Excel Worksheet Functions 3 November 3rd 05 07:48 PM
Wherre best to place code luke New Users to Excel 2 August 22nd 05 08:25 PM


All times are GMT +1. The time now is 05:13 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"