Solved

Find a cell to use  English to VBA?

Posted on 2014-04-22
10
247 Views
Last Modified: 2014-04-24
Here is the english version of what I need in VBA.

Start in A3 of the active sheet, if it is blank, select it, if it is not, skip a column and check again until and blank cell is found.

Example: It does not pick A3 (not blank), next it does not select C3 (its not blank either, however next check E3 is blank, select that one to use.
0
Comment
Question by:RWayneH
[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
  • 4
  • 3
  • 3
10 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40016057
Sub findblank()
    If IsEmpty(Range("A3")) Then
        Range("A3").Select
    ElseIf IsEmpty(Range("B3")) Then
        Range("B3").Select
    Else
        Range("A3").End(xlToRight).Offset(, 1).Select
    End If
End Sub
0
 
LVL 34

Expert Comment

by:Norie
ID: 40016061
Perhaps.
Cells(3, Columns.Count).End(xlToLeft).Offset(,1).Select

Open in new window

Or.
Cells(3,1).End(xlToRight).Offset(,1).Select

Open in new window

0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40016062
With fewer lines this one does looping

Sub findblank()
Dim cel
    For Each cel In Range("3:3")
        If IsEmpty(cel) Then cel.Select: Exit Sub
    Next cel
End Sub
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

Author Comment

by:RWayneH
ID: 40016092
Is this skipping a column?  It is not just the next blank...  I need a blank column between the checks.
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 40016102
Sub findblank()
Dim cel
    For Each cel In Range("3:3")
    if mod(cel.column,2)=1 then
        If IsEmpty(cel) Then cel.Select: Exit Sub
    Next cel
    Next cel
End Sub
0
 

Author Comment

by:RWayneH
ID: 40016116
if mod(cel.column,2)=1 then

failing
0
 
LVL 34

Expert Comment

by:Norie
ID: 40016120
Do you want to select all the blank cells in row 3?
For Each BlankCell In Rows(3).SpecialCells(xlCellTypeBlanks)
    ' do stuff with BlankCell
    BlankCell.Select
Next BlankCell

Open in new window

0
 
LVL 34

Expert Comment

by:Norie
ID: 40016123
Perhaps.
For I = 1 To Cells(3, Columns.Count).End(xlToLeft).Column Step 2
    If Cells(3, I).Value = "" Then
        Cells(3,I).Select
    End If
Next I

Open in new window

0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 40016124
Sorry that was excel format. This is the VBA format for mod

Sub findblank()
Dim cel
    For Each cel In Range("3:3")
    If cel.Column Mod 2 = 1 Then
        If IsEmpty(cel) Then cel.Select: Exit Sub
    End If
    Next cel
End Sub
0
 

Author Closing Comment

by:RWayneH
ID: 40020425
Thanks. -R-
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

734 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