Macros in Excel

G

Guest

Being new to Macros in Excel I just tried creating a simple exercise as
follows.
I have stored a value in cell j6 (row 1, col 10). I wish to check the value
if it is > 300 and if so, store valueof 500 in cell j7(row 1, col 11).

The script I entered in VB script editor. But when I executed the macro, I
encountered error.

defining a integer or string in VB is using
DIM ctr as integer
DIM flag as string.

Pl let me know how to define the cells in VB script(where I want the results
to be stored) i.e.,


Sub Macro1()

'
If j6 > 300 Then
j7 = 500


End If

'Application.CommandBars("Stop Recording").Visible = False
'Range("J8").Select
'Application.Goto Reference:="Macro1"
ActiveWorkbook.Save
ActiveWindow.SmallScroll Down:=-27
Range("K4").Select
Application.Goto Reference:="Macro1"
Application.WindowState = xlMinimized
Application.Goto Reference:="Macro1"
Application.Run "'dynam PROFORMA.xls'!Macro1"
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 5
ActiveWindow.ScrollRow = 4
ActiveWindow.ScrollRow = 3
ActiveWindow.ScrollRow = 2
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 3
Range("K6").Select
ActiveCell.FormulaR1C1 = "300"
Range("K6").Select
ActiveCell.FormulaR1C1 = "301"
Range("J6").Select
ActiveCell.FormulaR1C1 = "301"
Range("K6").Select
ActiveCell.FormulaR1C1 = " "
Range("J6").Select
ActiveWorkbook.Save
Range("J7").Select
Application.Width = 599.25
Application.Height = 429
Application.Run "'dynam PROFORMA.xls'!Macro1"
Application.CommandBars("Exit Design Mode").Visible = False
Range("J6").Select
ActiveWorkbook.Save
ActiveWorkbook.Save
End Sub
Tools - Macros -
 
T

Tom [Pepper] Willett

You should try an Excel newsgroup..this one is for FrontPage.
--
===
Tom [Pepper] Willett
Microsoft MVP - FrontPage
"You're a daisy if you do!"
---
FrontPage Support:
http://www.frontpagemvps.com/
===
: Being new to Macros in Excel I just tried creating a simple exercise as
: follows.
: I have stored a value in cell j6 (row 1, col 10). I wish to check the
value
: if it is > 300 and if so, store valueof 500 in cell j7(row 1, col 11).
:
: The script I entered in VB script editor. But when I executed the macro,
I
: encountered error.
:
: defining a integer or string in VB is using
: DIM ctr as integer
: DIM flag as string.
:
: Pl let me know how to define the cells in VB script(where I want the
results
: to be stored) i.e.,
:
:
: Sub Macro1()
:
: '
: If j6 > 300 Then
: j7 = 500
:
:
: End If
:
: 'Application.CommandBars("Stop Recording").Visible = False
: 'Range("J8").Select
: 'Application.Goto Reference:="Macro1"
: ActiveWorkbook.Save
: ActiveWindow.SmallScroll Down:=-27
: Range("K4").Select
: Application.Goto Reference:="Macro1"
: Application.WindowState = xlMinimized
: Application.Goto Reference:="Macro1"
: Application.Run "'dynam PROFORMA.xls'!Macro1"
: ActiveWindow.ScrollColumn = 2
: ActiveWindow.ScrollRow = 2
: ActiveWindow.ScrollRow = 3
: ActiveWindow.ScrollRow = 4
: ActiveWindow.ScrollRow = 5
: ActiveWindow.ScrollRow = 4
: ActiveWindow.ScrollRow = 3
: ActiveWindow.ScrollRow = 2
: ActiveWindow.ScrollRow = 1
: ActiveWindow.ScrollColumn = 3
: Range("K6").Select
: ActiveCell.FormulaR1C1 = "300"
: Range("K6").Select
: ActiveCell.FormulaR1C1 = "301"
: Range("J6").Select
: ActiveCell.FormulaR1C1 = "301"
: Range("K6").Select
: ActiveCell.FormulaR1C1 = " "
: Range("J6").Select
: ActiveWorkbook.Save
: Range("J7").Select
: Application.Width = 599.25
: Application.Height = 429
: Application.Run "'dynam PROFORMA.xls'!Macro1"
: Application.CommandBars("Exit Design Mode").Visible = False
: Range("J6").Select
: ActiveWorkbook.Save
: ActiveWorkbook.Save
: End Sub
: Tools - Macros -
: --
: reply to my posts are welcome
 

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