+ Reply to Thread
Results 1 to 2 of 2

Excel Macro - Triple Value

  1. #1
    Registered User
    Join Date
    02-23-2016
    Location
    USA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    6

    Excel Macro - Triple Value

    I have a macro that was created to double a number in a speadsheet. How can I use this macro to triple a number?


    Example would be ....

    245
    245
    245
    246
    246
    246
    247
    247
    247

    Here is the macro that I have.....


    Sub doublenum()
    Dim X As Long
    Dim rn As Long
    Dim cn As String
    Dim sn As Long

    cn = InputBox("Enter the column letter you want to populate.")
    rn = InputBox("Enter the number of rows you want to populate (Remember this doubles - example if you say 10 it will give you 20 rows).")
    sn = InputBox("What row do you want to start with?")
    X = InputBox("What number do you want to start counting at?")

    Application.ScreenUpdating = False
    Application.StatusBar = "Macro Running"
    X = X
    Range(cn & sn).Select
    Do Until ActiveCell.Row = rn + sn
    If ActiveCell.EntireRow.Hidden = False Then
    ActiveCell.Value = X
    X = X + 1
    End If
    ActiveCell.Offset(1).Select
    Loop
    Dim lr As Long
    lr = Range(cn & Rows.Count).End(xlUp).Row
    Dim i As Long
    For i = lr To sn + 1 Step -1
    Range(cn & i).EntireRow.Insert
    Next i
    lr = Range(cn & Rows.Count).End(xlUp).Row
    For i = 2 To lr
    If Range(cn & i) = "" Then Range(cn & i) = Range(cn & i - 1)
    Next i

    Application.ScreenUpdating = True
    Application.StatusBar = "Completed"
    End Sub



    Thanks in advance.

  2. #2
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Excel Macro - Triple Value

    Your original code contained 2 errors. The final number in your series was not being duplicated. Below is amended posted code, and below that is the code to triple
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by Kevin#; 03-01-2016 at 01:20 PM.

+ 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. triple if?
    By Evelyte in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-23-2013, 09:30 AM
  2. Need help with triple sumproduct, please
    By cmdill in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-03-2013, 08:33 PM
  3. Triple Search
    By mahdiking in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-24-2012, 07:12 PM
  4. Macro to triple filter a data in excel
    By marvinlajiant in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-28-2011, 02:10 PM
  5. Triple IF statement
    By JordanA in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2011, 02:30 PM
  6. triple Vlookup
    By savvito in forum Excel General
    Replies: 5
    Last Post: 10-15-2009, 10:03 AM
  7. Triple if, and, or 'or' fuction??
    By doowop5000 in forum Excel General
    Replies: 4
    Last Post: 09-25-2007, 06:43 AM
  8. triple-if function help???
    By doowop5000 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-25-2007, 06:13 AM

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