+ Reply to Thread
Results 1 to 2 of 2

Need assistance with a VBA that clears contents from the first blank in A through col I

  1. #1
    Registered User
    Join Date
    06-14-2019
    Location
    Chicago
    MS-Off Ver
    2016
    Posts
    0

    Need assistance with a VBA that clears contents from the first blank in A through col I

    Good afternoon experts!

    I am struggling with a couple codes. For "SFDC Data" I want to find the first blank in column A (last data set plus 1) and then clear contents from there through I2000. For "CP Raw Data" I want to find the first blank in column B and then clear contents from there through JB2000. I don't know how to set limits correctly. Your assistance would be GREATLY appreciated. I have the below so far:

    With Sheets("SFDC Data")
    last_row = .Range("A" & .Rows.Count).End(xlUp).Row
    End With
    For i = last_row To 1 Step -1
    If Cells(i, "A").Text <> "" Then
    Exit For
    End If
    Next i
    last_row = i
    With Sheets("SFDC Data")
    .Range("A" & i + 1, .Cells(.Rows.Count, .Columns.Count)).ClearContents
    End With
    With Sheets("CP Raw Data")
    last_row = .Range("B" & .Rows.Count).End(xlUp).Row
    End With
    For i = last_row To 1 Step -1
    If Cells(i, "B").Text <> "" Then
    Exit For
    End If
    Next i
    last_row = i
    With Sheets("CP Raw Data")
    .Range("B" & i + 1, .Cells(.Rows.Count, .Columns.Count)).ClearContents

  2. #2
    Administrator arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,147
    Hello cholula,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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] code multiple cells and clears the contents but get Method Range of object_ Global failed
    By dyoung785 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-01-2019, 10:54 PM
  2. Copy contents of cell before macro clears it
    By tm875430 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-14-2017, 03:40 PM
  3. Macro that clears cell contents on criteria
    By traderdays123 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-23-2017, 09:05 AM
  4. [SOLVED] VBA Code that Clears contents of specific column in row
    By Jamidd1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 07:49 AM
  5. Navivgation bar that activates selected sheet, then clears contents of the bar
    By jkindustries in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-24-2015, 08:53 AM
  6. Macro that clears contents of all cells of certain colour (colour 35) in all sheets
    By Hanskubansku in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-25-2012, 07:33 AM
  7. Macro clears contents and my formula references
    By moike in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-19-2006, 01:04 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