Results 1 to 9 of 9

need snippet to check two cells and paste into them if empty. if neither is empty, next i

Threaded View

Royzer need snippet to check two... 04-22-2016, 04:58 PM
jaslake Re: need snippet to check two... 04-22-2016, 05:39 PM
Royzer Re: need snippet to check two... 04-25-2016, 02:23 PM
jaslake Re: need snippet to check two... 04-25-2016, 02:32 PM
jaslake Re: need snippet to check two... 04-26-2016, 12:20 PM
Royzer Re: need snippet to check two... 05-09-2016, 02:02 PM
Royzer Re: need snippet to check two... 05-09-2016, 02:25 PM
jaslake Re: need snippet to check two... 05-09-2016, 02:50 PM
jaslake Re: need snippet to check two... 05-09-2016, 07:17 PM
  1. #1
    Forum Contributor
    Join Date
    04-29-2010
    Location
    Tallahassee, FL
    MS-Off Ver
    365
    Posts
    100

    Smile need snippet to check two cells and paste into them if empty. if neither is empty, next i

    Hi. I need a code snippet to make the attached code check two cells on a row and paste the data into them if they are empty. If they are not empty, the original code should take over until next i.

    I've uploaded a file with hopefully not too much detail. I would really appreciate it if you would take a look at it.


    The above is the most important thing, but...

    PS: I don't know if this should be a separate thread, so please let me know if it should: After the macro runs all the way through, it clears ALL of the data in column V instead of only clearing the data that was actually posted to the other location. I can work around that, but if there's a way to make it leave the unused data, that would awesome. Thanks!





    
    Option Explicit
    
    
    Sub AddDatesAmounts()
         
        Dim ObjDic   As Object
        Set ObjDic = CreateObject("Scripting.Dictionary")
        Dim LR  As Long
        Dim I  As Long
        Dim WkDate As Date
        Const FR As Integer = 4 '  First  Row  of  data
        Dim Temp
        Application.ScreenUpdating = False
          
         
        WkDate = Range("V1")
        With ObjDic
            LR = Range("U" & Rows.Count).End(3).Row
            For I = FR To LR
                If (Cells(I, "V") <> "") Then .Item(Cells(I, "U").Value & "/" & Cells(I, "V").Value) = Cells(I, "V").Value
            Next
            LR = Range("B" & Rows.Count).End(3).Row
            For I = FR To LR
            
                 
                If (Cells(I, "P") <> "") Then
                    Temp = Cells(I, "B").Value & "/" & Cells(I, "P").Value
                    If (.exists(Temp)) Then
                        If ((Cells(I, "L") = "") And (Cells(I, "M") = "")) Then
                            Cells(I, "L") = Format$(WkDate, "mm/dd/yy")
                            Cells(I, "M") = Cells(I, "P")
                            .Item(Temp) = ""
                        End If
                    End If
                End If
            Next I
            LR = Range("U" & Rows.Count).End(3).Row
            For I = FR To LR
                If (Cells(I, "V") <> "") Then
                    Temp = Cells(I, "U").Value & "/" & Cells(I, "V").Value
                     
                     'clears ALL amounts in "V"
                    If (.exists(Temp)) Then Cells(I, "V") = ""
                End If
            Next
        End With
        Application.ScreenUpdating = True
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Paste Values empty cell, not empty
    By warston in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 12-23-2020, 08:16 PM
  2. Need to check if cells empty before pasting
    By karlosdejackal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-05-2015, 03:20 PM
  3. Empty cells not evaluating as empty - multiple check methods tried
    By rafadavidc in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 02-03-2014, 05:54 PM
  4. Copy/Paste to Next Empty Row Overwriting Previous Row When Column A Is Empty
    By grantfitz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 04:34 PM
  5. Check cells and format empty
    By Gvlewis in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-22-2013, 02:55 PM
  6. check if sheet empty then paste value
    By celticpucca in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2011, 08:41 PM
  7. Check for empty cells but ignoring value ZERO
    By munkayboi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2007, 02:10 PM

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