Results 1 to 3 of 3

Excel VB Script to Enter Data based on whether a Cell is empty or not

Threaded View

timepass111 Excel VB Script to Enter Data... 09-19-2011, 12:05 AM
JBeaucaire Re: Excel VB Script to Enter... 09-19-2011, 03:48 AM
timepass111 Re: Excel VB Script to Enter... 09-19-2011, 10:27 AM
  1. #1
    Registered User
    Join Date
    09-17-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2003
    Posts
    5

    Excel VB Script to Enter Data based on whether a Cell is empty or not

    Hello everyone...

    I have to insert data into Column C of a spreadsheet based on whether Column A or B are empty or not.

    Attached excel file "test1.xls" shows the output format as well as what i have so far in terms of macro and here is the code which I have so far..

    Sub Macro2()
    
    Dim X As Integer
    
    Dim numb As Integer
    
    X = 2
    
    numb = 1
    
    Dim strFile As String
    
    Do
     
    If Not IsEmpty("B" & X) Then
        If Not IsEmpty("A" & X) Then
           
                strFile = Trim(ActiveSheet.Range("A" & X).Value) + ".pdf"
                ActiveCell.Value = strFile
    
            numb = numb + 1
            
            If numb > 4 Then
                Exit Sub
            End If
     X = X + 1
        End If
        
      X = X + 1
    
     ActiveCell.Offset(1, 0).Select
     ActiveSheet.Range("C" & X).Select
    
    End If
    
    Loop
      
    End Sub
    basically, as you would notice that the first 2 entries in Column C match the desired output because the number of entries in Column B is only one. The moment there are more entries than one in Column B, I am unable to skip the rows eg. skipping rows from C6 to C10 in this case.

    Any help in this regard is greatly appreciated...

    Thanks all in advance :-)
    Attached Files Attached Files
    Last edited by timepass111; 09-19-2011 at 10:32 AM. Reason: Query solved by Jerry

Thread Information

Users Browsing this Thread

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

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