Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Use column A to define "Range"

Posted on 2014-12-26
Medium Priority
109 Views
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

swjtx99
0
Question by:swjtx99
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 40518901
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

ID: 40519041
Hi Martin Liss,

Regards,

swjtx99
0

LVL 49

Expert Comment

ID: 40519049
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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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â€¦
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
###### Suggested Courses
Course of the Month9 days, 21 hours left to enroll