Results 1 to 4 of 4

Adding Column after checking if the value exists or not

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-13-2019
    Location
    Halifax, Canada
    MS-Off Ver
    2016
    Posts
    176

    Adding Column after checking if the value exists or not

    Hi experts,

    I have a data ranging from Column A to Column BX.

    I am trying to insert a column M (which already has a data) and put the value "Gross Sales" in M4. The VBA code that I have created, however, adds the column all the time since the code is run for multiple times for updating other operations. I have the following code and want to put a check event which checks Column M if value "Gross Sales" is available or not. If it is available do nothing and if it is not then add Column M and set "Gross Sales" in Cell M4. I appreciate for codes that will stop addition if the value "Gross Sales" exist in Column M.

    Dim sh1 As Worksheet
    
    Set sh1 = Worksheets("Original Data_Processed")
    
    sh1.Activate
    
    On Error Resume Next
    
    Range("M:M").Find(What:="Gross Sales").Select
        
        Range("M:M").EntireColumn.Insert
        Range("M4").Value = "Gross Sales"
       
    On Error GoTo 0
    
    End Sub
    Thank you
    Roshan Shakya
    Last edited by Roshan.Shakya; 07-10-2019 at 12:23 PM. Reason: for clarity

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Adding a Value to Column A when it Exists in Column B but not A
    By HCLax in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2015, 03:27 PM
  2. Checking to see if a number exists in a column
    By smaier69 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 12:08 PM
  3. [SOLVED] checking file exists before adding hyperlink
    By TaliKL in forum Excel General
    Replies: 8
    Last Post: 03-02-2013, 06:26 AM
  4. Replies: 4
    Last Post: 01-31-2012, 04:07 PM
  5. Adding up values after checking a column
    By Cmorgan in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 11-04-2011, 03:18 AM
  6. Adding up averages after checking another column
    By Cmorgan in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 09-20-2011, 06:34 AM
  7. help with checking if dir or file exists
    By greenfalcon in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2005, 03:03 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