Results 1 to 16 of 16

How to create macro with variable number of columns?

Threaded View

  1. #1
    Registered User
    Join Date
    04-01-2020
    Location
    Dublin, Ireland
    MS-Off Ver
    8
    Posts
    14

    How to create macro with variable number of columns?

    Hi, I have created a macro, but it is for a worksheet that has variable number of columns. In the code below, B7 will always be the start cell, but D35, could be E35 and so on, how do I deal with this please?
    Range("B7:D35").Select
        Selection.Borders(xlDiagonalDown).LineStyle = xlNone
        Selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With Selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlThin
    Last edited by alansidman; 04-01-2020 at 01:09 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using excel vba to create an if formula with variable columns
    By adles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-05-2019, 05:57 PM
  2. macro to create a table. Number of columns/rows unknown
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2017, 10:50 AM
  3. [SOLVED] Copy multiple columns x number of times based on variable number?
    By nobodyukno in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-19-2017, 04:13 PM
  4. Macro to cut and paste a variable number of rows to a variable location?
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2015, 07:57 AM
  5. Macro to insert a variable number of rows into a variable location
    By TheClaw2323 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2015, 05:31 AM
  6. sorting columns based on row criteria, with variable number of columns
    By bardobhb in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-02-2014, 04:02 PM
  7. [SOLVED] Macro to create columns by referencing a variable column
    By mactoolsix in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2014, 05:19 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