+ Reply to Thread
Results 1 to 2 of 2

Using declared variables to refer to row in Row() function.

Hybrid View

  1. #1
    Registered User
    Join Date
    07-13-2016
    Location
    Stockholm
    MS-Off Ver
    2013
    Posts
    27

    Using declared variables to refer to row in Row() function.

    Lets say i = 9 and I want to delete the 9. row in a worksheet, sheet1, by only using i to refer to the row.

    I use the following code:

    i = 9
    Debug.Print ("""" & i & ":" & i & """")
    Worksheets("sheet1").Rows("""" & i & ":" & i & """").Delete Shift:=xlUp

    My first line debug prints: "9:9"
    So one should think I refer to row 9 correctly. Writing: Worksheets("sheet1").Rows("9:9").Delete Shift:=xlUp
    also works

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Using declared variables to refer to row in Row() function.

    You should be able to just put the 9 in the ()

        Dim s As String
        s = InputBox("What Row?")
        Rows(s).Delete Shift:=xlUp

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Declared Variables and Stored Values
    By fireflydreams in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2015, 12:39 PM
  2. Declared variables in excel vba
    By RALIR in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-12-2015, 06:05 PM
  3. Do/Loop Until using variables declared
    By LLL0422 in forum Excel Programming / VBA / Macros
    Replies: 33
    Last Post: 06-05-2014, 09:01 AM
  4. Problem with public global declared variables
    By vonb3ta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2013, 07:20 AM
  5. [SOLVED] Macro for autofilter using variables declared in worksheet
    By Jeff in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  6. Macro for autofilter using variables declared in worksheet
    By Jeff in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. [SOLVED] Macro for autofilter using variables declared in worksheet
    By Jeff in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1