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

O

osman

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: (e-mail address removed)

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 Where:=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 Where:=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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top