Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Macro Code Needs Revision

Posted on 2013-01-19
7
Medium Priority
?
220 Views
Last Modified: 2013-01-19
Hello Experts,

I am using this code...

Sub ClearMeasuringUp()
    If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo) = vbYes Then
        ActiveSheet.Range("B28:D28,F28:H28,J28:L28,P28").ClearContents
        Application.Goto Reference:="Diameter"
        Selection.ClearContents
    End If
End Sub

Open in new window


After the "Selection.ClearContents" - I need the code to go to cell N7 and type the word "Diameter".

Thank you in advance for your help!

~ Geekamo
0
Comment
Question by:Geekamo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 2000 total points
ID: 38796496
Sub ClearMeasuringUp()
    If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo) = vbYes Then
        ActiveSheet.Range("B28:D28,F28:H28,J28:L28,P28").ClearContents
        Activesheet.Cells(7, 14).Value = "Diameter"
        Application.Goto Reference:="Diameter"
        Selection.ClearContents
    End If
End Sub
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38797693
@ MartinLiss,

I am now using this code...

Sub ClearMeasuringUp()
    If MsgBox("You are about to clear the entire worksheet - Are you sure you want to proceed?", vbYesNo) = vbYes Then
        ActiveSheet.Range("B28:D28,F28:H28,J28:L28,P28").ClearContents
        ActiveSheet.Cells(27, 14).Value = "Diameter"
        Application.Goto Reference:="Diameter"
        Selection.ClearContents
    End If
End Sub

My original cell reference in my post wasn't correct.  So I see that 27, represents row #, and 14 represents the 14th column.  Mind you I know nothing about code, but can't you just reference the cell via it's cell name N27?

~ Geekamo
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 38797725
Yes, you can

ActiveSheet.Range("A27").Value = "Diameter"

They're both the same and in this case using Range is easier but I've gotten into the habit of using Cells because in the code I write I often have to increment the column and it's much easier to do that with Cells.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:Geekamo
ID: 38797739
@ MartinLiss,

Great, this works perfectly! Ya, I guess for me it's easier seeing the range.  I get by, by reusing pieces of code cause this is all beyond me.

Thanks!

~ Geekamo
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 38797741
If you want to learn you can Google something like Excel VBA tutorial.
0
 
LVL 1

Author Comment

by:Geekamo
ID: 38797745
@ MartinLiss,

Ya, I definitely want to get more into it. I been watching Mr. Excel on YouTube and it's only been after watching some of his videos that things started clicking.  The workbook I'm working on is probably the most advanced one I've done.  I'm super excited!

~ Geekamo
0
 
LVL 49

Expert Comment

by:Martin Liss
ID: 38797768
Glad I was able to help.

Marty  - MVP 2009 to 2012
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question