#1   Report Post  
monty
 
Posts: n/a
Default adapt macro

If I have the following macro running in worksheet 1.
This will generate a numeric value starting with 1

Option Explicit
Sub RCA()

ActiveSheet.UsedRange
If Range("A1").Value = "" Then
Range("A1").Value = InputBox("Enter starting
value")
Else
Range("A1").SpecialCells
(xlCellTypeLastCell).Offset(1, 0).Value =
Application.WorksheetFunction.Max(Range("A:A")) + 1
End If
End Sub

How can I adapt this macro to run in worksheet 2 & 3. If
I want worksheet 2 to start with PCI1 then PCI2 and so on
and then I want worksheet 3 to start with PCICR1 then
PCICR2.

Thanks

Monty

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default

Try something like

Sub RCA(sh as worksheet)

With sh
.UsedRange
If .Range("A1").Value = "" Then
.Range("A1").Value = InputBox("Enter starting value")
Else
.Range("A1").SpecialCells(xlCellTypeLastCell).Offs et(1, 0).Value
= _
Application.WorksheetFunction.Max(.Range("A:A")) + 1
End If
End With
End Sub


and use like so

RCA Activesheet
RCA Worksheets("Sheet2")
RCA Worksheets("Sheet3")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"monty" wrote in message
...
If I have the following macro running in worksheet 1.
This will generate a numeric value starting with 1

Option Explicit
Sub RCA()

ActiveSheet.UsedRange
If Range("A1").Value = "" Then
Range("A1").Value = InputBox("Enter starting
value")
Else
Range("A1").SpecialCells
(xlCellTypeLastCell).Offset(1, 0).Value =
Application.WorksheetFunction.Max(Range("A:A")) + 1
End If
End Sub

How can I adapt this macro to run in worksheet 2 & 3. If
I want worksheet 2 to start with PCI1 then PCI2 and so on
and then I want worksheet 3 to start with PCICR1 then
PCICR2.

Thanks

Monty



  #3   Report Post  
Monty
 
Posts: n/a
Default

Soz

When i insert this as a module and i go to run as macro
nothing appears. i suppose i'm doing something incorrect
can you please help.

-----Original Message-----
Try something like

Sub RCA(sh as worksheet)

With sh
.UsedRange
If .Range("A1").Value = "" Then
.Range("A1").Value = InputBox("Enter

starting value")
Else
.Range("A1").SpecialCells

(xlCellTypeLastCell).Offset(1, 0).Value
= _
Application.WorksheetFunction.Max(.Range

("A:A")) + 1
End If
End With
End Sub


and use like so

RCA Activesheet
RCA Worksheets("Sheet2")
RCA Worksheets("Sheet3")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"monty" wrote in

message
...
If I have the following macro running in worksheet 1.
This will generate a numeric value starting with 1

Option Explicit
Sub RCA()

ActiveSheet.UsedRange
If Range("A1").Value = "" Then
Range("A1").Value = InputBox("Enter starting
value")
Else
Range("A1").SpecialCells
(xlCellTypeLastCell).Offset(1, 0).Value =
Application.WorksheetFunction.Max(Range("A:A")) + 1
End If
End Sub

How can I adapt this macro to run in worksheet 2 & 3.

If
I want worksheet 2 to start with PCI1 then PCI2 and so

on
and then I want worksheet 3 to start with PCICR1 then
PCICR2.

Thanks

Monty



.

  #4   Report Post  
Bob Phillips
 
Posts: n/a
Default

A little difficult from afar.

A bit of detail as to what your final code looks like and what happens might
help.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Monty" wrote in message
...
Soz

When i insert this as a module and i go to run as macro
nothing appears. i suppose i'm doing something incorrect
can you please help.

-----Original Message-----
Try something like

Sub RCA(sh as worksheet)

With sh
.UsedRange
If .Range("A1").Value = "" Then
.Range("A1").Value = InputBox("Enter

starting value")
Else
.Range("A1").SpecialCells

(xlCellTypeLastCell).Offset(1, 0).Value
= _
Application.WorksheetFunction.Max(.Range

("A:A")) + 1
End If
End With
End Sub


and use like so

RCA Activesheet
RCA Worksheets("Sheet2")
RCA Worksheets("Sheet3")

--

HTH

RP
(remove nothere from the email address if mailing direct)


"monty" wrote in

message
...
If I have the following macro running in worksheet 1.
This will generate a numeric value starting with 1

Option Explicit
Sub RCA()

ActiveSheet.UsedRange
If Range("A1").Value = "" Then
Range("A1").Value = InputBox("Enter starting
value")
Else
Range("A1").SpecialCells
(xlCellTypeLastCell).Offset(1, 0).Value =
Application.WorksheetFunction.Max(Range("A:A")) + 1
End If
End Sub

How can I adapt this macro to run in worksheet 2 & 3.

If
I want worksheet 2 to start with PCI1 then PCI2 and so

on
and then I want worksheet 3 to start with PCICR1 then
PCICR2.

Thanks

Monty



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Playing a macro from another workbook Jim Excel Discussion (Misc queries) 1 February 23rd 05 10:12 PM
Date macro Hiking Excel Discussion (Misc queries) 9 February 3rd 05 12:40 AM
Can't get simple macro to run Abi Excel Worksheet Functions 5 January 12th 05 07:37 PM
Macro and If Statement SATB Excel Discussion (Misc queries) 2 December 3rd 04 04:46 PM
Macro for multiple charts JS Excel Worksheet Functions 1 November 19th 04 03:44 AM


All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"