ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Do Until (https://www.excelbanter.com/excel-programming/388596-vba-do-until.html)

Brent E

VBA Do Until
 
Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,

JE McGimpsey

VBA Do Until
 
One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


Dave Peterson

VBA Do Until
 
I think JE wanted to come down a row after the assignment:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Set rB = rB.Offset(1, 0)
Loop

A personal preference:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do
if isempty(rb.value) then
exit do
end if
rB.Offset(0, -1).Formula = csFORMULA
Set rB = rB.Offset(1, 0)
Loop



JE McGimpsey wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


--

Dave Peterson

Brent E

VBA Do Until
 
I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,



Dave Peterson

VBA Do Until
 
Maybe:

Const csFORMULA = "=IF(RC[1]<"""","""",ISNUMBER(MATCH(RC[1]," & _
"'[QA_Accounts_Overview2007.xls]LB SUMMARIES '!C1,0)))"

Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).FormulaR1C1 = csFORMULA
Set RB = RB.Offset(1, 0)
Loop
Range("A2").Select



Brent E wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,



--

Dave Peterson

Dave Peterson

VBA Do Until
 
ps. There's an extra space after Summaries. Sorry.

Dave Peterson wrote:

Maybe:

Const csFORMULA = "=IF(RC[1]<"""","""",ISNUMBER(MATCH(RC[1]," & _
"'[QA_Accounts_Overview2007.xls]LB SUMMARIES '!C1,0)))"

Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).FormulaR1C1 = csFORMULA
Set RB = RB.Offset(1, 0)
Loop
Range("A2").Select

Brent E wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


--

Dave Peterson


--

Dave Peterson

Brent E

VBA Do Until
 
Dave, I just tried your second formula too, but am getting an error on
rB.Offset(0, -1).Formula = csFORMULA

Any ideas?

This is code I used:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do
if isempty(rb.value) then
exit do
end if
rB.Offset(0, -1).Formula = csFORMULA
Set rB = rB.Offset(1, 0)
Loop



"Brent E" wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,



Brent E

VBA Do Until
 
Dave,

I just tried this and still errors on line
RB.Offset(0, -1).FormulaR1C1 = csFORMULA

I initially had the code plug the formula in to a cell in Col A then copy
the cell, select entire colA, and paste special as formula, but this filled
entire page way past the end of my data in Col B.

Is there a way to maybe do something similar but only as Col B has data?


"Dave Peterson" wrote:

Maybe:

Const csFORMULA = "=IF(RC[1]<"""","""",ISNUMBER(MATCH(RC[1]," & _
"'[QA_Accounts_Overview2007.xls]LB SUMMARIES '!C1,0)))"

Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).FormulaR1C1 = csFORMULA
Set RB = RB.Offset(1, 0)
Loop
Range("A2").Select



Brent E wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


--

Dave Peterson


JE McGimpsey

VBA Do Until
 
In article ,
Dave Peterson wrote:

I think JE wanted to come down a row after the assignment:


Yep - once again not pasting the tested version back into the
newsreader. Thanks for the correction.

Dave Peterson

VBA Do Until
 
Maybe it's time to share the string in csFormula again.

=====
After you get that formula correct, you may want to just plop that formula into
all the cells in the range in one step:

with activesheet
.Range("A1:A" & .cells(.rows.count,"B").end(xlup).row).formular1c1 _
= csformula
end with

But this won't help until you figure out what's wrong with that formula.

Try typing it in A1 manually.
Then switch to R1C1 reference style.
Then copy the formula from the formulabar and post this in your response.

(remember to switch back to A1 reference style if you
want--tools|Options|general tab))

Brent E wrote:

Dave,

I just tried this and still errors on line
RB.Offset(0, -1).FormulaR1C1 = csFORMULA

I initially had the code plug the formula in to a cell in Col A then copy
the cell, select entire colA, and paste special as formula, but this filled
entire page way past the end of my data in Col B.

Is there a way to maybe do something similar but only as Col B has data?

"Dave Peterson" wrote:

Maybe:

Const csFORMULA = "=IF(RC[1]<"""","""",ISNUMBER(MATCH(RC[1]," & _
"'[QA_Accounts_Overview2007.xls]LB SUMMARIES '!C1,0)))"

Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).FormulaR1C1 = csFORMULA
Set RB = RB.Offset(1, 0)
Loop
Range("A2").Select



Brent E wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


--

Dave Peterson


--

Dave Peterson

Brent E

VBA Do Until
 
OK, I was able to get the formula to work now, but for some reason is still
pasting the formula in ColA past the end of my data in Col B.

Any thoughts?

By the way thank u both for all your assistance.

"Brent E" wrote:

Dave, I just tried your second formula too, but am getting an error on
rB.Offset(0, -1).Formula = csFORMULA

Any ideas?

This is code I used:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do
if isempty(rb.value) then
exit do
end if
rB.Offset(0, -1).Formula = csFORMULA
Set rB = rB.Offset(1, 0)
Loop



"Brent E" wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,


Gord Dibben

VBA Do Until
 
Brent

What is in the cells in column B that the code ignores as blank?

Maybe an extraneous space or a formula that returns "" which is not blank,
just looks like it.


Gord Dibben MS Excel MVP

On Wed, 2 May 2007 12:15:02 -0700, Brent E
wrote:

OK, I was able to get the formula to work now, but for some reason is still
pasting the formula in ColA past the end of my data in Col B.

Any thoughts?

By the way thank u both for all your assistance.

"Brent E" wrote:

Dave, I just tried your second formula too, but am getting an error on
rB.Offset(0, -1).Formula = csFORMULA

Any ideas?

This is code I used:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do
if isempty(rb.value) then
exit do
end if
rB.Offset(0, -1).Formula = csFORMULA
Set rB = rB.Offset(1, 0)
Loop



"Brent E" wrote:

I tried your formula w/ my own slight variation:

Const csFORMULA =
"=IF(RC[1]<"""""""",,ISNUMBER(MATCH(RC[1],'[QA_Accounts_Overview2007.xls]LB
SUMMARIES'!C1,0)))"
Dim RB As Range
Set RB = Range("B1")
Do Until IsEmpty(RB.Value)
RB.Offset(0, -1).Formula = csFORMULA
Loop
Range("A2").Select

I am getting an error on this line:
RB.Offset(0, -1).Formula = csFORMULA

Please advise.

Thanks,

"JE McGimpsey" wrote:

One way:

Const csFORMULA = "<your formula here"
Dim rB As Range
Set rB = Range("B1")
Do Until IsEmpty(rB.Value)
rB.Offset(0, -1).Formula = csFORMULA
Loop

In article ,
Brent E wrote:

Good morning,

I need a VBA module to do the following:

For each cell in ColB that is not blank or null,
paste formula in ColA corresponding cell.

So something like
Do Until
ColB cell is blank

Paste formula in colA cell

End.

Please assist.

Thanks Much,




All times are GMT +1. The time now is 05:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com