ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   go to next columb (https://www.excelbanter.com/excel-programming/421704-go-next-columb.html)

oderf

go to next columb
 
I have a template on worksheet 1, worksheet 2 is the monthly totals from the
daily. I am trying to get excel to choose the next columb if there is info in
the columb. the formula "IF(ISBLANK(a2),sheet2!b2+b2,XXX). what is the code
for XXX to get the curror to go to the next columb for the same IF statement.


Susan

go to next columb
 
a formula can't make a cursor move to another column. it can only
work within the cell that the formula is in. you are asking for code,
but what you have written is a formula.

if you want the VBA code for such a scenario, it would be something
like this (although your description is not very specific and i don't
know if it have understood you correctly):

if worksheet("Sheet1").range("a2").value = "" then
worksheet("Sheet1").range("a2").value = "=Sheet1!B2+Sheet2!B2"
else
worksheet("Sheet1").range("a3").select
end if

but that only does it once. you'd have to set a range and then do a
For Each Next loop to go through the range cell by cell.
hope that gets you started.
:)
susan


On Dec 24, 1:30*pm, oderf wrote:
I have a template on worksheet 1, worksheet 2 is the monthly totals from the
daily. I am trying to get excel to choose the next columb if there is info in
the columb. the formula "IF(ISBLANK(a2),sheet2!b2+b2,XXX). what is the code
for XXX to get the curror to go to the next columb for the same IF statement.




All times are GMT +1. The time now is 06:23 PM.

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