Solved

Use column A to define "Range"

Posted on 2014-12-26
3
91 Views
Last Modified: 2014-12-26
Hi,

An Expert provided me with code that worked fine for the original use but when I tried to adapt it for another problem, I ran into a bit of trouble. The below looks at every row from 1-65536 and where column L has a blank, it writes the word "Blank" into column R and then copies whatever value is in Column K to Column L.

The problem with this is it still writes the word "Blank" after the end of the data-set, (because column L is obviously blank in every row after the end of the data-set.)

What I need is to define the range by looking at column A (which will never have any blanks), and then proceed to execute the rest of the code. I've tried several modifications of the "For Myrow =..." line but I haven't found the solution yet.

Dim Myrow As Long

   For Myrow = 1 To 65536 'you can change the 65536 and decrease / increase for any row quantities you want / need
        If UCase(Range("L" & Myrow).Value) = "" Then
         Range("R" & Myrow).Value = "Blank"
         Range("L" & Myrow).Value = Range("K" & Myrow).Value
     End If
     Next Myrow

Thanks in advance,

swjtx99
0
Comment
Question by:swjtx99
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 total points
Comment Utility
Dim lngLastRow as Long

lngLastRow = Range("A1048576").End(xlUp).Row
For Myrow = 1 To lngLastRow 'you can change the 65536 and decrease / increase for any row quantities you want / need
        If UCase(Range("L" & Myrow).Value) = "" Then
         Range("R" & Myrow).Value = "Blank"
         Range("L" & Myrow).Value = Range("K" & Myrow).Value
     End If
     Next Myrow
0
 

Author Closing Comment

by:swjtx99
Comment Utility
Hi Martin Liss,

Thanks for your help.

Regards,

swjtx99
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now