Active Cell not first Cell

bromy2004

Board Regular
Joined
Feb 8, 2008
Messages
63
Hi Everyone,

I have a macro that mimics pressing F2 & Enter to reformat the cells.
Code:
Sub F2_Enter()
Dim NUM As Integer
Dim c As Range

On Error Resume Next
    NUM = Application.InputBox(Prompt:="Repeat how many times?", Title:="Choose", Default:=Selection.Count, Type:=1)
Range(Cells(ActiveCell.Row, ActiveCell.Column), Cells(ActiveCell.Row + NUM - 1, _
    ActiveCell.Column)).Select

For Each c In Selection
    c.FormulaR1C1 = c.Value
Next

End Sub

it helps with converting numbers to Text and back.
however i'm getting a problem when i select from a higher row that the Lowest.
i.e. i click and drag from A10 to A5
Range A5:A10
but the active cell is still A10 instead of A5.

how can this be changed?

the Range can be anywhere from 5 cells to 10000 cells
 
Last edited:

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Spark of inspiration.
for anyone else who has the same problem add this code
Code:
Cells(Selection.Row, Selection.Column).Activate
 
Upvote 0
Final Macro for anyone who wants to know
Code:
Sub F2_Enter()
Dim NUM As Integer
Dim c As Range
Dim d As String
Dim calc As String
Dim CurrentRange
Dim CurrentCell

'Performance
calc = Application.Calculation
Application.Calculation = xlManual
Application.ScreenUpdating = False

'Current Selection
CurrentRange = Application.Selection.Address
CurrentCell = Application.ActiveCell.Address

'Macro
On Error Resume Next
If Selection.Areas.Count = 1 Then
    NUM = Application.InputBox(Prompt:="Repeat how many times?", Title:="Choose", Default:=Selection.Count, Type:=1)
    Cells(Selection.Row, Selection.Column).Activate
    Range(Cells(ActiveCell.Row, ActiveCell.Column), Cells(ActiveCell.Row + NUM - 1, _
    ActiveCell.Column)).Select

    For Each c In Selection
        d = c.Value
        c.FormulaR1C1 = ""
        c.Value = d
    Next
Else
MsgBox "To stop confusion, only select one range"
End If

'select origional Data
Application.Range(CurrentRange).Select
Application.Range(CurrentCell).Activate

Application.Calculation = calc
Application.ScreenUpdating = True

End Sub

i think its pretty self explanatory
Any tips??? let me know.
:)

Bromy
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top