How to Format an imported embeded object

simmo

New Member
Joined
Oct 28, 2002
Messages
36
My active worksheet is TEST, macro 1 imports another excel worksheet, sizes, positions it and renames it as NEW. Macro 2 contains the formating I want to perform on the embeded object NEW before I finish macro 1.
Can anyone help
Here is the code so far
Sub Macro1()
'
' Macro1 Macro
'
Sheets("Test").OLEObjects.Add(Filename:="C:Program Filesdata.xls", Link:=False).Name = "new"
With Sheets("test").OLEObjects("new")
.Left = 100
.Top = 133
.Width = 70
.Height = 35
.ShapeRange.Fill.ForeColor.SchemeColor = 40
.Name = "data 1" & Time
End With
Sheets("Test").Activate
End Sub

Sub Macro2()
'
' Macro2 Macro
' min vals
' Keyboard Shortcut: Ctrl+a
'
' Sub FormatMinimum()
Range("C4:C120,E4:E120,G4:G120,I4:I120,K4:K120,L4:L120").Interior.ColorIndex = 0

Dim MinRange1 As Range, MinRange2 As Range, MinRange3 As Range, MinRange4 As Range, MaxRange5 As Range, MaxRange6 As Range

Dim MinVal1 As Long, MinVal2 As Long, MinVal3 As Long, MinVal4 As Long, MaxVal5 As Long, MaxVal6 As Long

Set MinRange1 = Range("N4:N120")
Set MinRange2 = Range("O4:O120")
Set MinRange3 = Range("P4:P120")
Set MinRange4 = Range("Q4:Q120")
Set MaxRange5 = Range("K4:K120")
Set MaxRange6 = Range("L4:L120")

MinVal1 = Application.WorksheetFunction.Min(MinRange1)
MinRange1.Find(What:=MinVal1, After:=Range("N4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Offset(0, -11).Interior.ColorIndex = 44

MinVal2 = Application.WorksheetFunction.Min(MinRange2)
MinRange2.Find(What:=MinVal2, After:=Range("O4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Offset(0, -10).Interior.ColorIndex = 44

MinVal3 = Application.WorksheetFunction.Min(MinRange3)
MinRange3.Find(What:=MinVal3, After:=Range("P4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Offset(0, -9).Interior.ColorIndex = 44

MinVal4 = Application.WorksheetFunction.Min(MinRange4)
MinRange4.Find(What:=MinVal4, After:=Range("Q4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Offset(0, -8).Interior.ColorIndex = 44

MaxVal5 = Application.WorksheetFunction.Max(MaxRange5)
MaxRange5.Find(What:=MaxVal5, After:=Range("K4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Interior.ColorIndex = 4

MaxVal6 = Application.WorksheetFunction.Max(MaxRange6)
MaxRange6.Find(What:=MaxVal6, After:=Range("L4"), LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False).Interior.ColorIndex = 3

Rows("1:1").Delete Shift:=xlUp
Range("A1:Q2").Interior.ColorIndex = 37
Range("A1:B20").Interior.ColorIndex = 37
Range("C2:M2").Interior.ColorIndex = 35
Columns("N:Q").Delete
Columns("A:B").EntireColumn.AutoFit
Range("A1").Select

End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top