Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 12-21-2016, 11:20 PM
NoSparks NoSparks is offline Button does not generate proper colors? Windows 7 64bit Button does not generate proper colors? Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

The little black marker in the lower right corner of cell H whatever row that is indicates column I is not part of the table.

Try this
Code:
Sub CloudForgiven()

    Dim colIndex As Variant
    Dim StrtRow As Long, EndRow As Long, i As Long
    Dim oLo As ListObject
    
    colIndex = Application.InputBox("Enter a column that you want to add: ", "What column?")
    If colIndex = "" Then Exit Sub
    With ThisWorkbook.Sheets("Sheet1")
        .Columns(colIndex).Insert shift:=xlRight  '<--| reference column you want to insert
        
        'sheet row numbers from table rows
        Set oLo = .ListObjects(1)    '<~~ first table on sheet
        With oLo
            StrtRow = .ListRows(1).Range.Row
            EndRow = .ListRows.Count + StrtRow - 1
        End With
    
        For i = StrtRow To EndRow
            .Cells(i, colIndex).Interior.Color = .Cells(i, 1).DisplayFormat.Interior.Color
        Next i
    End With

End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
proper snoforlife Excel Programming 0 01-26-2016 02:16 PM
Button does not generate proper colors? Hyperlinks Not Linking to Proper Sections of Doc MoiraB Word 2 08-26-2015 07:13 PM
Proper Text Format sufian,naeem Excel 1 05-05-2014 05:59 AM
Button does not generate proper colors? Unable to change font colors from theme colors choy Word 3 08-01-2012 09:12 PM
Button does not generate proper colors? Proper Excel Table of Contents (ToC) judicial85 Excel 1 10-23-2011 01:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:25 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft