Macro to end of spreadsheet

Dlanders05

New Member
Joined
Mar 17, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
It can't be this hard. Please. ...and thank you so much.
  • Data is all in column A.
  • Using a Cut/Paste to place data in a single row.
  • Need macro to go to end of spreadsheet.
  • Delete all blank rows.
  • Would like to run this macro in multiple spreadsheets.
Sub NIC()
'
' NIC Macro
'
' Keyboard Shortcut: Ctrl+Shift+A
'
Range("A431").Select
Selection.Cut Destination:=Range("C430")
Range("A432").Select
Selection.Cut Destination:=Range("B430")
Range("A433").Select
Selection.Cut Destination:=Range("D430")
Range("D430").Select
ActiveWindow.SmallScroll Down:=8
Range("A435").Select
Selection.Cut Destination:=Range("C434")
Range("A436").Select
Selection.Cut Destination:=Range("B434")
Range("A437").Select
Selection.Cut Destination:=Range("D434")
Range("D434").Select
End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
It can't be this hard. Please. ...and thank you so much.
  • Data is all in column A.
  • Using a Cut/Paste to place data in a single row.
  • Need macro to go to end of spreadsheet.
  • Delete all blank rows.
  • Would like to run this macro in multiple spreadsheets.
Sub NIC()
'
' NIC Macro
'
' Keyboard Shortcut: Ctrl+Shift+A
'
Range("A431").Select
Selection.Cut Destination:=Range("C430")
Range("A432").Select
Selection.Cut Destination:=Range("B430")
Range("A433").Select
Selection.Cut Destination:=Range("D430")
Range("D430").Select
ActiveWindow.SmallScroll Down:=8
Range("A435").Select
Selection.Cut Destination:=Range("C434")
Range("A436").Select
Selection.Cut Destination:=Range("B434")
Range("A437").Select
Selection.Cut Destination:=Range("D434")
Range("D434").Select
End Sub
Hello
"It can't be this hard." If this is true why are you asking for help?
Try something like:

Sub GoToTheEnd()
Dim lLastRow As Long

lLastRow = ActiveSheet.Range("A1").End(xlDown).Row
End Sub

lLastRow will have the row number of the last occupied cell. From there you can navigate to where you need to go. Remember there are 1048576 rows in a worksheet (Excel 2007 and newer)

This will go to the last occupied cell if:
A) There are no empty (blank) cells in the column you are working with. In this case it will be Column A.
B) There is data past a certain number of rows, in this case Row 1.

Play with this, and if you still need help come back with your questions

Monty
 
Upvote 0
Can you post a sample of how your data looks like? And also a sample of the output that you are looking for? Because the cell references in your VBA code looks random to me.

As for the last row in column A. You can use this:
VBA Code:
Dim lastRow As Long
lastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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