NOTE: Scheduled Maintenance for July 5th from 8PM-9PM EDT
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Business Applications
Tag Cloud
audio blue screen boot bsod computer connection crash dell drivers dvd email error excel firefox graphics hard drive hardware hijackthis install internet itunes keyboard laptop malware monitor motherboard network outlook outlook 2003 outlook 2007 problem registry cleaner registry cleaners router screen slow sound trojan ubuntu upgrade usb video virus vista windows windows 7 windows vista windows xp wireless word
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Business Applications >
Solved: Excel 2003 VBA

Tip: Click Here to Update All Your PC's Outdated Drivers
[ Sponsored Link ]

Closed Thread
 
Thread Tools
computerman29642's Avatar
Computer Specs
Distinguished Member with 2,394 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Always Learning!
16-Jun-2008, 02:46 PM #1
Solved: Excel 2003 VBA
I am trying to create a VBA that run when the workbook is opened. If D8 is not blank, then the next cell (E8) will be selected. If D8 is blank, then D8 will be selected. The code needs to look through cell I8.
Rollin_Again's Avatar
Distinguished Member with 3,421 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
16-Jun-2008, 04:31 PM #2
Open the Excel workbook. Just to the left of the FILE menu is a small Excel icon. Right click it and select VIEW CODE. When the VBA editor opens look for the combobox at the top of the editor that says "General." Change this value to "Workbook" and the Workbook_Open sub should be created automatically for you. This is where you put your code. Instead of using multiple IF statements you should use a loop to evaluate each cells until you find the first empty cell that meets your condtions. I can help with the loop but need to know what happens if all cells between D8 and I8 contains values?

Code:
Private Sub Workbook_Open()

If IsEmpty(Range("D8")) Then
Range("D8").Select
Else
Range("E8").Select
End If

End Sub



Regards,
Rollin
__________________
Protect your computer and keep it free of pests and other spyware. Download AdAware, Spybot, ZoneAlarm and lots of other great utilities at PC World / SnapFiles / Major Geeks, Tech Guy Stuff

Help Keep this site free by making a small donation

http://www.techguy.org/donate.html

tsghelp at live dot com / support

Last edited by Rollin_Again : 16-Jun-2008 05:44 PM.
computerman29642's Avatar
Computer Specs
Distinguished Member with 2,394 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Always Learning!
16-Jun-2008, 04:54 PM #3
Quote:
I can help with the loop but need to know what happens if all cells between D8 and I8 contains values?
If cells between D8 & I8 contain values, then I would like for cell K4 to be selected.
Rollin_Again's Avatar
Distinguished Member with 3,421 posts.
 
Join Date: Sep 2003
Location: Atlanta, GA - Planet Earth
Experience: Brilliant When Sober
16-Jun-2008, 05:11 PM #4
Here are a couple of different ways you can do this

Code:
Private Sub Workbook_Open()

For Each vCell In Range("D8:I8")
If IsEmpty(vCell) Then
vCell.Select
Exit Sub
End If
Next
Range("K4").Select

End Sub
or

Code:
Private Sub Workbook_Open()

If Application.Evaluate("COUNTA(D8:I8)") = 6 Then
Range("K4").Select
Else
vStartCol = 4
If IsEmpty(Cells(8, vStartCol)) Then
Cells(8, vStartCol).Select
Else
Do While vStartCol <= 9 And Not IsEmpty(Cells(8, vStartCol))
vStartCol = vStartCol + 1
Loop
Cells(8, vStartCol).Select
End If
End If

End Sub
Regards,
Rollin

Last edited by Rollin_Again : 16-Jun-2008 05:49 PM.
computerman29642's Avatar
Computer Specs
Distinguished Member with 2,394 posts.
 
Join Date: Dec 2007
Location: HERE OR THERE?!?!?!
Experience: Always Learning!
17-Jun-2008, 08:02 AM #5
Thnaks Rollin. The code(s) you provided works great.
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:21 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Powered by Cermak Technologies, Inc.