Prev Previous Post   Next Post Next
  #1   Report Post  
matt
 
Posts: n/a
Default simplify code

Hi,

I'm pretty new to writing code, so I wanted to ask for some advice. I've got
a code which checks to see if cells in two columns are equal, and if they are
not, it inserts blank cells in three columns. It works, but it is pretty
slow, as I have written three separate IF statements for inserting blank
cells. Is there any way that I can condense this into one IF statement? the
code I am using so far is:

LastRow = ActiveSheet.Cells(Rows.Count, "b").End(xlUp).Row
Range("E1").Select
For j=1 To LastRow
If Range("b" & j) < Range("a" & j) Then Range("b" & j).Select
Selection.Insert Shift:=xlDown
If Range("b" & j) < Range("a" & j) Then Range("c" & j).Select
Selection.Insert Shift:=xlDown
If Range("b" & j) < Range("a" & j) Then Range("d" & j).Select
Selection.Insert Shift:=xlDown
Range("e" & j).Select
Next j

Any help would be greatly appreciated.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change case...help please Terry Excel Worksheet Functions 14 October 2nd 05 12:29 PM
Macro for changing text to Proper Case JPriest Excel Worksheet Functions 3 August 8th 05 09:31 PM
Using other workbooks.. DavidMunday Excel Worksheet Functions 2 July 1st 05 07:35 AM
Make Change Case in Excel a format rather than formula Kevin Excel Worksheet Functions 1 March 18th 05 08:53 PM
Opening a file with code without a set file name jenkinspat Excel Discussion (Misc queries) 1 March 4th 05 10:50 AM


All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"