Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel 2013 - VB code for a simple process to move down a single row

Posted on 2014-11-12
5
Medium Priority
?
97 Views
Last Modified: 2014-11-17
I only know a little about VB - enough to be dangerous. If I have the following code, how can I change it to move down a single row without it naming a specific range – “A1342” in this example????? I do not want it to put the actual range in there; I just want to move down a single row. Thanks.

Sub Remove_Blanks()
'
' Remove_Blanks Macro
' Delete blank rows
'

'
    Range("A1342").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.EntireRow.Delete
    ActiveSheet.ShowAllData
    Range("A2").Select
End Sub
0
Comment
Question by:esu4236
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 36

Expert Comment

by:Kimputer
ID: 40437908
Assuming you want the code to change to where you put your cursor (or to be more exact, the cell you clicked):

Sub Remove_Blanks()
'
' Remove_Blanks Macro
' Delete blank rows
'

'
    ActiveCell.Select
    
    Range(Selection, Selection.End(xlDown)).Select
    Selection.EntireRow.Delete
    If ActiveSheet.FilterMode = True Then
        ActiveSheet.ShowAllData
    End If
    Range("A2").Select
End Sub

Open in new window


Your code is set to delete stuff, while your post mentions moving down, which is basically a different thing. I left the code as it is, until you ask for other instructions.
0
 

Author Comment

by:esu4236
ID: 40437959
Ignoring the deleting of the blank rows part, I just want the line of code shown below to move down a single row rather than going to this particular cell:

Range("A1342").Select
0
 

Accepted Solution

by:
esu4236 earned 0 total points
ID: 40437983
The user figured it out - It was the Offset(1,0).  Thanks.
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 40437990
Sub Move_down()
'
' select current
' Jump one cell down

    ActiveCell.Select
    Selection.Offset(1, 0).Select
    
End Sub

Open in new window


This code just jumps one down. From where you clicked the last time (as you said, you don't want to specify the cell, which means you have to click a cell and then run this code)
0
 

Author Closing Comment

by:esu4236
ID: 40446861
Because a user on my end figured it out.
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question