PC Review


Reply
Thread Tools Rate Thread

macros creating

 
 
=?Utf-8?B?TlNOUg==?=
Guest
Posts: n/a
 
      26th Oct 2007
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
Thanks
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RlN0MQ==?=
Guest
Posts: n/a
 
      26th Oct 2007
hi,
cells are range objects and need not be defined. instead just use the value
property of the range object. to do what you want try this...
Sub test1()
If Range("J6").Value > 300 Then
Range("J7").Value = 500
End If
End Sub
variables need defining. same as above only different.
Sub Test2()
Dim jjj6 As Range 'j6 is reserved for vb/xl
Dim jjj7 As Range
Dim c As Long 'variable for do nothing example
Set jjj6 = Cells(10, 6)
Set jjj7 = Cells(10, 7)
'range("J6") is the same as Cells(10, 6)
c = 1 ' do nothing example
If jjj6.Value > 300 Then
jjj7.Value = 500
End If
MsgBox "the value of c is " & c 'do nothing example
End Sub
for a list of data types, in vb help type Data Type then click data type
summary.
it will probably been greek to you but there are the types.

hope this helped
regards
FSt1
"NSNR" wrote:

> 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
> Thanks

 
Reply With Quote
 
 
 
 
=?Utf-8?B?TlNOUg==?=
Guest
Posts: n/a
 
      26th Oct 2007
Many thanks for the timely reply.

with Regards

--
reply to my posts are welcome


"FSt1" wrote:

> hi,
> cells are range objects and need not be defined. instead just use the value
> property of the range object. to do what you want try this...
> Sub test1()
> If Range("J6").Value > 300 Then
> Range("J7").Value = 500
> End If
> End Sub
> variables need defining. same as above only different.
> Sub Test2()
> Dim jjj6 As Range 'j6 is reserved for vb/xl
> Dim jjj7 As Range
> Dim c As Long 'variable for do nothing example
> Set jjj6 = Cells(10, 6)
> Set jjj7 = Cells(10, 7)
> 'range("J6") is the same as Cells(10, 6)
> c = 1 ' do nothing example
> If jjj6.Value > 300 Then
> jjj7.Value = 500
> End If
> MsgBox "the value of c is " & c 'do nothing example
> End Sub
> for a list of data types, in vb help type Data Type then click data type
> summary.
> it will probably been greek to you but there are the types.
>
> hope this helped
> regards
> FSt1
> "NSNR" wrote:
>
> > 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
> > Thanks

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run multiple Macros or macros from within other macros ? vbaNEWBIE Microsoft Outlook VBA Programming 2 10th Feb 2010 11:14 PM
Macros Macros Macros - Is there anybody out there who is a whiz? =?Utf-8?B?TXIuIFNtaWxleQ==?= Microsoft Access 2 30th Aug 2005 11:11 PM
Passing documents with macros and toolbar icons for the macros SteveK Microsoft Powerpoint 1 7th Feb 2005 08:24 PM
Doc has no macros, but I'm prompted to enable/disable macros Microsoft Word Document Management 2 7th Oct 2004 09:34 AM
Re: List the Macros that can be executed from Tools-Macros Rob Bovey Microsoft Excel Programming 1 10th Jul 2003 05:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:01 PM.