|
-
Feb 1st, 2007, 12:50 PM
#1
Thread Starter
Addicted Member
[RESOLVED]Looping - if Cell value is blank go to next i
Hi,
I am looping through a list of items and if a certain cell is blank i am to skip the next couple of steps and go to the next item in the loop
inside the loop i have attempted this, but it wont compile so obviously there is something wrong
ranInd is a range, so if this value is blank i want to go to the next range
cheers
VB Code:
If ranInd.Cells(9).Value <> "" Then
Next i
End If
Last edited by Mitch_s_s; Feb 3rd, 2007 at 08:00 AM.
-
Feb 1st, 2007, 01:35 PM
#2
Re: Looping - if Cell value is blank go to next i
you could use a goto (although try to avoid it)
post the full loop code...so we can see where and how to tweak it
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 01:37 PM
#3
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
i'm at home now soi cant post it
i havent finished the code for the loop
but i need a way to start the next item
didnt really want to use go to
-
Feb 1st, 2007, 01:50 PM
#4
Re: Looping - if Cell value is blank go to next i
I usually do somthing like this..
test right off the bat... if its not blank.. do your code.. otherwise it will skip it all
VB Code:
For X = 1 To 100
If ranInd.Cells(9).Value <> "" Then
'Do normal stuff
End If
Next
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Feb 1st, 2007, 01:54 PM
#5
Re: Looping - if Cell value is blank go to next i
skip the next couple of steps
How are your other range(s) placed? at regular intervals or are they at random places?
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 1st, 2007, 03:12 PM
#6
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
its two rows down
so i offset(2)
-
Feb 1st, 2007, 03:38 PM
#7
Re: Looping - if Cell value is blank go to next i
Hmm, I understand
Ok, last two questions...
Does every range have fixed number of cells? for example
range1= "a1:a5" (say 5 cells)
then after two rows...
range2= "a8:a12"
then after two rows...
range3= "a15:a19"
and so on?
and the 2nd question
Are then a specific number of ranges for example 5 ranges or 10 ranges?
Sorry for asking to many questions. It's just that I need to be sure before posting a solution...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 1st, 2007, 03:53 PM
#8
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
no its ok, i appreciate any help so i am happy to answer any questions
my range is for example
B2:H3
then i offset 2
but before i go into the loop i have put a counta formula in cell B1
and i then store this as my i for the count, just so i know how many loops there will be
but not all of these ranges are valid
-
Feb 1st, 2007, 04:08 PM
#9
Re: Looping - if Cell value is blank go to next i
my range is for example
B2:H3
then i offset 2
but before i go into the loop i have put a counta formula in cell B1
and i then store this as my i for the count, just so i know how many loops there will be
but not all of these ranges are valid
I am sorry, I didnt get it but
No I won't ask you more questions...
is it possible to upload your workbook so that I can understand it more clearly...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Feb 2nd, 2007, 03:12 AM
#10
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
I will upload shortly
say my first range is B2:H3
My next range would be B4:H5
i want to be able to skip the range if a certain cell is blank
and i know the maximum number of ranges i will have as in cell B1 the formula is
=counta(B2:B1000)
i then store this value into i(my count)
and take one off it each time i loop
-
Feb 2nd, 2007, 03:45 AM
#11
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
This is what i have come up with
there may be easier ways i dont know....
VB Code:
range("J2:J3").select
Do Until i = range("B1").value
If ActiveCell.Value = "" Then
Selection.EntireRow.Delete
End If
i = i + 1
Selection.Offset(2).Select
Loop
-
Feb 2nd, 2007, 03:46 AM
#12
Thread Starter
Addicted Member
Re: Looping - if Cell value is blank go to next i
i put the above, before my main loop
this appears to have fixed it
let me know if you have any other approaches
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|