ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro help (https://www.excelbanter.com/excel-discussion-misc-queries/43109-macro-help.html)

candyyoung

macro help
 

I am just learning Excel and I am trying to add a formula to some cells
to do multiple functions. Here is what I am trying to do: IF G2=1 and
H2=1, add "1" to E2 and delete G2 and H2. I have been told I need to
create a macro for this. Any help on how to do it?


--
candyyoung
------------------------------------------------------------------------
candyyoung's Profile: http://www.excelforum.com/member.php...o&userid=26795
View this thread: http://www.excelforum.com/showthread...hreadid=400543


Dave Peterson

I think your code (with no validation at all!) would look something like:

Option Explicit
Sub testme01()

With Worksheets("sheet1")
If .Range("g2").Value = 1 _
And .Range("H2").Value = 1 Then
.Range("e2").Value = .Range("e2").Value + 1
.Range("g2:h2").ClearContents
End If
End With

End Sub

But when you run it is a question to me.

candyyoung wrote:

I am just learning Excel and I am trying to add a formula to some cells
to do multiple functions. Here is what I am trying to do: IF G2=1 and
H2=1, add "1" to E2 and delete G2 and H2. I have been told I need to
create a macro for this. Any help on how to do it?

--
candyyoung
------------------------------------------------------------------------
candyyoung's Profile: http://www.excelforum.com/member.php...o&userid=26795
View this thread: http://www.excelforum.com/showthread...hreadid=400543


--

Dave Peterson


All times are GMT +1. The time now is 07:30 AM.

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