Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 20th, 2011, 10:48 AM
Friend of Wrox
Points: 429, Level: 7
Points: 429, Level: 7 Points: 429, Level: 7 Points: 429, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 103
Thanks: 7
Thanked 0 Times in 0 Posts
Default VBA code to create duplicate lines

Hi

I was wondering if anyone could help me with a vba macro i am trying to build.

Currently I have a workbook with table which looks like this:

Row1 1SPACE1SPACE1
Row2 1
Row3

However I need to macro make the table look like this:

Row1 1
Row1SPACE1
Row1SPACE SPACE1
Row2 1

What I need the macro to do is say if the cells in columns 2-4 are empty then delete the row. If the cells in columns 2-4 only have one cell with data ignore it. If multiple cells in columns 2-4 only have data then create a new line so that each number on that row has its own line.

I have managed to create a piece of code which looks at whether the row is empty however I can seem to find a way of doing the rest. The code i have created needs to have variables for the row number as this is not always the same. Currently the code i have is:

Code:
    StartLine = Sheets("Sheet1").Range("B24").Value
    
    EndLine = Sheets("Sheet1").Range("B25").Value

    For i = EndLine To StartLine Step -1

    Cells(i, 9).Select

    If Cells(i, 9) = "" Then
                    
        If Cells(i, 10) = "" Then
        If Cells(i, 11) = "" Then
        If Cells(i, 12) = "" Then
        If Cells(i, 13) = "" Then
                           
            Cells(i, 13).EntireRow.Delete
                    
        End If
        End If
        End If
        End If
        
    End If
Can anyone help me??

Thanks

Jeskit

Last edited by jeskit; December 20th, 2011 at 10:58 AM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
lines of code nandar_hayhay C# 5 April 8th, 2009 12:09 AM
How can i create VBA code to Insert a Module? stylin99 Excel VBA 1 January 18th, 2008 10:01 PM
Read Excel Lines VBA gbvdh VB How-To 0 February 26th, 2007 08:44 AM
how to create duplicate error message??? elleetan Access 1 September 16th, 2003 10:47 PM



All times are GMT -4. The time now is 04:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.