ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need Help with Macro Code (https://www.excelbanter.com/excel-programming/342406-need-help-macro-code.html)

[email protected]

Need Help with Macro Code
 
Hello!
I need some help with a macro code for excel. I'm a beginner who
doesn't know quite how to do begin. I have records in rows in an Excel
spread sheet, I need code that would check each record to see if data
is present in column AB cell. If AB is NOT blank, I need it to check if
column AA cell is blank. If it AA is blank, I need it to copy the data
from column B cell to column AA cell...again only if column AB is not
blank and AA is blank (if AB is blank, it shouldn't do anything). Hope
that made sense. Thanks in advance for all your help.


Bob Phillips[_6_]

Need Help with Macro Code
 

For i = 1 To Cells(Rows.Count,"AB").End(xlUp).Row
If Cells(i,"AB").Value < "" Then
If Cells(i,"AA").Value = "" Then
Cells(i,"AA"),value = Cells(i,"B").Value
End If
End If
Next i

--
HTH

Bob Phillips

wrote in message
ups.com...
Hello!
I need some help with a macro code for excel. I'm a beginner who
doesn't know quite how to do begin. I have records in rows in an Excel
spread sheet, I need code that would check each record to see if data
is present in column AB cell. If AB is NOT blank, I need it to check if
column AA cell is blank. If it AA is blank, I need it to copy the data
from column B cell to column AA cell...again only if column AB is not
blank and AA is blank (if AB is blank, it shouldn't do anything). Hope
that made sense. Thanks in advance for all your help.




[email protected]

Need Help with Macro Code
 
Hello, Bob! Thanks for the help. I tried your code but got the
following error
Compile error: syntax error on the Cells(i,"AA"),value =
Cells(i,"B").Value line
Any ideas on how to fix? Thanks!


Dave Peterson

Need Help with Macro Code
 
It was a typo:

Cells(i,"AA"),value
should have been:

Cells(i,"AA").Value



wrote:

Hello, Bob! Thanks for the help. I tried your code but got the
following error
Compile error: syntax error on the Cells(i,"AA"),value =
Cells(i,"B").Value line
Any ideas on how to fix? Thanks!


--

Dave Peterson

[email protected]

Need Help with Macro Code
 
I tried fixing the typo but I'm getting the same error on the same
line. Any ideas? thanks!

Dave Peterson wrote:
It was a typo:

Cells(i,"AA"),value
should have been:

Cells(i,"AA").Value



wrote:

Hello, Bob! Thanks for the help. I tried your code but got the
following error
Compile error: syntax error on the Cells(i,"AA"),value =
Cells(i,"B").Value line
Any ideas on how to fix? Thanks!


--

Dave Peterson



Bob Phillips[_6_]

Need Help with Macro Code
 
Juts tested it with the typo fixed, works as I read the requiremnet.

--
HTH

Bob Phillips

wrote in message
oups.com...
I tried fixing the typo but I'm getting the same error on the same
line. Any ideas? thanks!

Dave Peterson wrote:
It was a typo:

Cells(i,"AA"),value
should have been:

Cells(i,"AA").Value



wrote:

Hello, Bob! Thanks for the help. I tried your code but got the
following error
Compile error: syntax error on the Cells(i,"AA"),value =
Cells(i,"B").Value line
Any ideas on how to fix? Thanks!


--

Dave Peterson





[email protected]

Need Help with Macro Code
 
My mistake. It does work! I had a typo some where else on the line.
Sorry about that. THANKS for your help!!!


[email protected]

Need Help with Macro Code
 
My mistake. It does work! I had a typo some where else on the line.
Sorry about that. THANKS for your help!!!


[email protected]

Need Help with Macro Code
 
My mistake. It does work! I had a typo some where else on the line.
Sorry about that. THANKS for your help!!!



All times are GMT +1. The time now is 11:13 AM.

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