VBA causing cell to change incorrectly

Bouncy Fire

New Member
Joined
Feb 20, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,
An ex employee created this spreadsheet with Macros and I have updated and added additional line entries. I have been able to fix a few issues, however I have one cell that continues to change incorrectly.
The Macros enable to change the range of cells J3:J56.
Example, the text PSTP1400 in cell J3, using Ctrl+M changes the text to PSTP1400A. Then using Ctrl +N takes it back to the original text PSTP1400.
When using Ctrl+M cell J56 which contains returns the same result as cell J55. Then using Ctrl+N cell J56 returns the same result as cell J55.

Sub Marine_Grade()
'
' Marine_Grade Macro
'
' Keyboard Shortcut: Ctrl+m
'
Range("J3").Select
ActiveCell.FormulaR1C1 = "='Post Codes'!R[-2]C[-9] &""A"""
Range("J3").Select
Selection.AutoFill Destination:=Range("J3:J58"), Type:=xlFillDefault
Range("J3:J58").Select
ActiveWindow.SmallScroll Down:=6
Range("J56").Select
ActiveCell.FormulaR1C1 = "='Post Codes'!R[-3]C[-9] &""A"""
Range("J58").Select
ActiveCell.FormulaR1C1 = "PSTP3100A-Q"
Range("J56").Select
ActiveWindow.SmallScroll Down:=-12
Range("J3").Select
End Sub
Sub Normal_Posts()
'
' Normal_Posts Macro
'
' Keyboard Shortcut: Ctrl+n
'
Range("J3").Select
ActiveCell.FormulaR1C1 = "='Post Codes'!R[-2]C[-9] &"""""
Range("J3").Select
Selection.AutoFill Destination:=Range("J3:J58"), Type:=xlFillDefault
Range("J3:J58").Select
ActiveWindow.SmallScroll Down:=18
Range("J56").Select
ActiveCell.FormulaR1C1 = "='Post Codes'!R[-3]C[-9] &"""""
Range("J58").Select
ActiveCell.FormulaR1C1 = "PSTP3100-Q"
Range("J56").Select
ActiveWindow.SmallScroll Down:=-21
Range("J3").Select
End Sub

Any help would be greatly appreciated.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Looks like your added lines may have changed the math for the original Macros since they are coded in absolutes. A solution would be very hard without the data and intent.
 
Upvote 0
Looks like your added lines may have changed the math for the original Macros since they are coded in absolutes. A solution would be very hard without the data and intent.
Thank you for response.
Xl2bb has the 'minisheet' is greyed out. is there another way to show data and intent?
 
Upvote 0
It kinda looks like your ex employee just hit the Record Macro button and manually performed a task. All the cells were always the same.
 
Upvote 0
It kinda looks like your ex employee just hit the Record Macro button and manually performed a task. All the cells were always the same.
Agree, I think he also used the recording. It's just not making sense, why only one cell J56 is returning the information from Cell J55, and all other cells work correctly.
 
Upvote 0

Attachments

  • Before using the Marco Ctrl+M.JPG
    Before using the Marco Ctrl+M.JPG
    172.9 KB · Views: 10
  • After using the Marco Ctrl+M.JPG
    After using the Marco Ctrl+M.JPG
    177.8 KB · Views: 12
  • After using the Marco Ctrl+N.JPG
    After using the Marco Ctrl+N.JPG
    188.7 KB · Views: 10
Upvote 0
Yeah. I would actually have to see the file before it was changed. I can see that the formula in J55 refers to cell A53 which doesn't have any data in it which is why it does work.
 
Upvote 0
Yeah. I would actually have to see the file before it was changed. I can see that the formula in J55 refers to cell A53 which doesn't have any data in it which is why it does work.
Unless I'm looking at only one of multiple sheets.
 
Upvote 0
cell J55 has formula (='Post Codes'!A53 &"") which comes from another tab. See attached.
 

Attachments

  • Post Codes Tab.JPG
    Post Codes Tab.JPG
    59.1 KB · Views: 8
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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