Typed text changes cell

XDamian

New Member
Joined
Apr 19, 2010
Messages
9
I created simple macros that do the same thing. A text is typed when clicking on a button that runs my macro.
I created then a macro to delete the texts that I typed.
The texts generated by my macros appear in cells different to those I originally chose when creating my macro.
My Excel version is very old (2003).
Why does my text jump?
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,491
Office Version
365, 2010
Platform
Windows, Mobile
I wouldn't imagine that anyone would be able to give a good response until you post your macros ;)
 

XDamian

New Member
Joined
Apr 19, 2010
Messages
9
Sub Clean()
'
' Clean Macro
' Macro grabada el 26/09/2019 por Damian
'
'
Range("G2:G100").Select
Selection.ClearContents
End Sub
Sub A_149_1()
'
' A_149_1 Macro
' Macro grabada el 26/09/2019 por Damian
'
'
ActiveCell.FormulaR1C1 = "Doing a test on macros"
Range("G4").Select
End Sub
Sub A_149_2()
'
' A_149_2 Macro
' Macro grabada el 26/09/2019 por Damian
'
'
ActiveCell.FormulaR1C1 = _
"This text typed in G5 appears in G2 when I activate the macro"
Range("G5").Select
End Sub

Texts are typed in G4 and G5.
Macro is activated with a button that has been created.
Texts appear in some line in the G column.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,491
Office Version
365, 2010
Platform
Windows, Mobile
Your ActiveCell when the text is placed in the cell is G2 because of the first line in your sub where you select the range to be cleared. You don't need to use select.
 

XDamian

New Member
Joined
Apr 19, 2010
Messages
9
ok. What can I use instead of select, if I want the cells to be deleted?.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,491
Office Version
365, 2010
Platform
Windows, Mobile
...
Code:
Range("G2:G100").ClearContents
Also
Code:
Range("G4").Value = "Doing a test on macros"
And the same syntax for G5 if you don't actually need the ActiveCell to change.
 
Last edited:

XDamian

New Member
Joined
Apr 19, 2010
Messages
9
...
Code:
Range("G2:G100").ClearContents
Also
Code:
Range("G4").Value = "Doing a test on macros"
And the same syntax for G5 if you don't actually need the ActiveCell to change.
Thanks, but that does not work.
Syntaxis error.
Thanks for the suggestion.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,491
Office Version
365, 2010
Platform
Windows, Mobile
I can't see any syntax error.
 

XDamian

New Member
Joined
Apr 19, 2010
Messages
9
So much better for you ( no syntax error).
Now the text appears wherever it wants.
Thanks for your effort.
 

Forum statistics

Threads
1,082,316
Messages
5,364,483
Members
400,802
Latest member
RichBRich

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top