Solved

Use column A to define "Range"

Posted on 2014-12-26
3
103 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
[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
  • Learn & ask questions
  • 2
3 Comments
 
LVL 47

Accepted Solution

by:
Martin Liss earned 500 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

by:swjtx99
ID: 40519041
Hi Martin Liss,

Thanks for your help.

Regards,

swjtx99
0
 
LVL 47

Expert Comment

by:Martin Liss
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
A WS within a WS 11 38
Simplify construction of formula 4 57
VBA how to use Like operator with phrasal verb? 4 24
Excel formula to calculate ID # 4 39
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

738 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