ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Macro to open file, load & do charts, functional but not usable/not a good prog (https://www.excelbanter.com/excel-programming/361597-excel-macro-open-file-load-do-charts-functional-but-not-usable-not-good-prog.html)

osman[_2_]

Excel Macro to open file, load & do charts, functional but not usable/not a good prog
 

I have been working on this for a while, after using help, recorded I
have something but it is not quite OK. I would like someone to look at
code and chop the ugly parts and help me make it work all together fine.
When I run the macro to do charts, it works fine. but when i run the
browse command and load file this way I cannot ran charts. Thanks for
your expert guys/gals.
My macro has two buttoms 1, to let you search(browse) for your file,
the other to run the charts.
Email:

Private Sub CommandButton1_Click()
Call Browser
End Sub


Private Sub RunChart_Click()
Call IFMBOW
End Sub

Sub IFMBOW()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+p
'

Dim F_cell As Range
Dim L_cell As Range
Dim F1 As String
Dim L1 As String


Set F_cell = Cells.Find(what:="@da$sha_x")
Set L_cell = Cells.FindPrevious().Next

F1 = F_cell.Address([ReferenceStyle:=xlA1])
L1 = L_cell.Address([ReferenceStyle:=xlA1])


Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(F1 & ":" &
L1), PlotBy:=xlColumns


ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
..HasTitle = True
..ChartTitle.Characters.Text = "@dA$SHA_X"
..Axes(xlCategory, xlPrimary).HasTitle = False
..Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveWindow.Visible = False
Windows("Book1.xls").Activate
'Range("m10").Select

Set F_cell = Nothing
Set L_cell = Nothing
F1 = 0
L1 = 0


Set F_cell = Cells.Find(what:="@da$sha_y")
Set L_cell = Cells.FindPrevious().Next

F1 = F_cell.Address([ReferenceStyle:=xlA1])
L1 = L_cell.Address([ReferenceStyle:=xlA1])


Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(F1 & ":" &
L1), PlotBy:=xlColumns

ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
..HasTitle = True
..ChartTitle.Characters.Text = "@dA$SHA_Y"
..Axes(xlCategory, xlPrimary).HasTitle = False
..Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveWindow.Visible = False
Windows("Book1.xls").Activate

'Range("j45").Select



End Sub

Sub Browser()

Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
..AllowMultiSelect = True
..Show

' Display paths of each file selected
For lngCount = 1 To 1 '.SelectedItems.Count
'MsgBox .SelectedItems(lngCount)
Workbooks.Open Filename:=.SelectedItems(lngCount)

Set NewSheet = Sheets.Add(Type:=xlWorksheet)
For i = 1 To Sheets.Count
NewSheet.Cells(i, 1).Value = Sheets(i)
Next i

Next lngCount

End With

End Sub


--
osman
------------------------------------------------------------------------
osman's Profile:
http://www.excelforum.com/member.php...o&userid=34226
View this thread: http://www.excelforum.com/showthread...hreadid=542477



All times are GMT +1. The time now is 10:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com