Solved

Find a cell to use  English to VBA?

Posted on 2014-04-22
10
248 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

628 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