Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
I am making.. or trying to make a macro to clear data from fields on my
sheet. I keep on getting different error messages and nothing I have found so far ( going on 60.00 worth of books) have help me find that anwser.. I am going to take a class... i am in more urgent needs of anwsers. do.. you want me to post the code? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
On 21 Apr, 08:02, Chris wrote:
I am making.. or trying to make a macro to clear data from fields on my sheet. I keep on getting different error messages and nothing I have found so far ( going on 60.00 worth of books) have help me find that anwser.. I am going to take a class... i am in more urgent needs of anwsers. do.. you want me to post the code? Chris, Use the Clearcontents command: Range("First cells ref:Second cell ref").clearcontents e.g. Range("A1:B20").clearcontents where the range is the range that you want to clear. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
Hi Briziers,
You should post the relevant code and indicate both the line that is highlighted when the code errors, and the error message whiich you encounter. --- Regards, Norman "Brizers" wrote in message oups.com... On 21 Apr, 08:02, Chris wrote: I am making.. or trying to make a macro to clear data from fields on my sheet. I keep on getting different error messages and nothing I have found so far ( going on 60.00 worth of books) have help me find that anwser.. I am going to take a class... i am in more urgent needs of anwsers. do.. you want me to post the code? Chris, Use the Clearcontents command: Range("First cells ref:Second cell ref").clearcontents e.g. Range("A1:B20").clearcontents where the range is the range that you want to clear. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
Apologies Norman, it was Chris who asked the question (I suggested an
answer). For reference, this was: Range("First cell reference:Second cell reference").Clearcontents e.g. Range("A1:B20").Clearcontents |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
Hi Briers,
Sorry! My post was intended as a reponse to Chris but I inadvertently appended it to the wrong strand. --- Regards, Norman "Brizers" wrote in message oups.com... Apologies Norman, it was Chris who asked the question (I suggested an answer). For reference, this was: Range("First cell reference:Second cell reference").Clearcontents e.g. Range("A1:B20").Clearcontents |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
there you go... have at it... Private Sub CommandButton1_Click() Sub Clear() ' ' Clear Macro ' Macro recorded 4/17/2007 by marrech ' ' Range("F18:F19").Select ActiveCell.FormulaR1C1 = "" Range("G18:G19").Select ActiveCell.FormulaR1C1 = "" Range("H18:H19").Select ActiveCell.FormulaR1C1 = "" Range("I18:I19").Select ActiveCell.FormulaR1C1 = "" Range("J18:J19").Select ActiveCell.FormulaR1C1 = "" Range("F27:F28").Select ActiveCell.FormulaR1C1 = "" Range("G27:G28").Select ActiveCell.FormulaR1C1 = "" Range("H27:H28").Select ActiveCell.FormulaR1C1 = "" Range("I27:I28").Select ActiveCell.FormulaR1C1 = "" Range("J27:J28").Select ActiveCell.FormulaR1C1 = "" Range("C16").Select ActiveCell.FormulaR1C1 = "" Range("C17").Select ActiveCell.FormulaR1C1 = "" Range("C18").Select ActiveCell.FormulaR1C1 = "" Range("C19").Select ActiveCell.FormulaR1C1 = "" Range("C20").Select ActiveCell.FormulaR1C1 = "" Range("C21").Select ActiveCell.FormulaR1C1 = "" Range("C22").Select ActiveCell.FormulaR1C1 = "" Range("C23").Select ActiveCell.FormulaR1C1 = "" Range("C24").Select ActiveCell.FormulaR1C1 = "" Range("C25").Select ActiveCell.FormulaR1C1 = "" Range("C26").Select ActiveCell.FormulaR1C1 = "" Range("C27").Select ActiveCell.FormulaR1C1 = "" Range("C28").Select ActiveCell.FormulaR1C1 = "" Range("C29").Select ActiveCell.FormulaR1C1 = "" Range("C30").Select ActiveCell.FormulaR1C1 = "" Range("D32").Select ActiveCell.FormulaR1C1 = "" Range("D33").Select ActiveCell.FormulaR1C1 = "" Range("D34").Select ActiveCell.FormulaR1C1 = "" Range("H32").Select ActiveCell.FormulaR1C1 = "" Range("I32").Select ActiveCell.FormulaR1C1 = "" Range("J32").Select ActiveCell.FormulaR1C1 = "" Range("K32").Select ActiveCell.FormulaR1C1 = "" Range("L32").Select ActiveCell.FormulaR1C1 = "" Range("L33").Select ActiveCell.FormulaR1C1 = "" Range("K33").Select ActiveCell.FormulaR1C1 = "" Range("J33").Select ActiveCell.FormulaR1C1 = "" Range("I33").Select ActiveCell.FormulaR1C1 = "" Range("H33").Select ActiveCell.FormulaR1C1 = "" Range("H34").Select ActiveCell.FormulaR1C1 = "" Range("I34").Select ActiveCell.FormulaR1C1 = "" Range("J34").Select ActiveCell.FormulaR1C1 = "" Range("K34").Select ActiveCell.FormulaR1C1 = "" Range("L34").Select ActiveCell.FormulaR1C1 = "" Range("L35").Select ActiveCell.FormulaR1C1 = "" Range("K35").Select ActiveCell.FormulaR1C1 = "" Range("J35").Select ActiveCell.FormulaR1C1 = "" Range("I35").Select ActiveCell.FormulaR1C1 = "" Range("H35").Select ActiveCell.FormulaR1C1 = "" Range("H38").Select End Sub End Sub |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
Hi Chris,
Your 98 lines of code can be condensed to a single instruction Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents Notr that your code had two headers: Private Sub CommandButton1_Click() Sub Clear() and two closing lines: End Sub End Sub Additionally, it is not necessary to select a range in order to clear its contents and it is not necessary to clear the cells individually. --- Regards, Norman "Chris" wrote in message ... there you go... have at it... Private Sub CommandButton1_Click() Sub Clear() ' ' Clear Macro ' Macro recorded 4/17/2007 by marrech ' ' Range("F18:F19").Select ActiveCell.FormulaR1C1 = "" Range("G18:G19").Select ActiveCell.FormulaR1C1 = "" Range("H18:H19").Select ActiveCell.FormulaR1C1 = "" Range("I18:I19").Select ActiveCell.FormulaR1C1 = "" Range("J18:J19").Select ActiveCell.FormulaR1C1 = "" Range("F27:F28").Select ActiveCell.FormulaR1C1 = "" Range("G27:G28").Select ActiveCell.FormulaR1C1 = "" Range("H27:H28").Select ActiveCell.FormulaR1C1 = "" Range("I27:I28").Select ActiveCell.FormulaR1C1 = "" Range("J27:J28").Select ActiveCell.FormulaR1C1 = "" Range("C16").Select ActiveCell.FormulaR1C1 = "" Range("C17").Select ActiveCell.FormulaR1C1 = "" Range("C18").Select ActiveCell.FormulaR1C1 = "" Range("C19").Select ActiveCell.FormulaR1C1 = "" Range("C20").Select ActiveCell.FormulaR1C1 = "" Range("C21").Select ActiveCell.FormulaR1C1 = "" Range("C22").Select ActiveCell.FormulaR1C1 = "" Range("C23").Select ActiveCell.FormulaR1C1 = "" Range("C24").Select ActiveCell.FormulaR1C1 = "" Range("C25").Select ActiveCell.FormulaR1C1 = "" Range("C26").Select ActiveCell.FormulaR1C1 = "" Range("C27").Select ActiveCell.FormulaR1C1 = "" Range("C28").Select ActiveCell.FormulaR1C1 = "" Range("C29").Select ActiveCell.FormulaR1C1 = "" Range("C30").Select ActiveCell.FormulaR1C1 = "" Range("D32").Select ActiveCell.FormulaR1C1 = "" Range("D33").Select ActiveCell.FormulaR1C1 = "" Range("D34").Select ActiveCell.FormulaR1C1 = "" Range("H32").Select ActiveCell.FormulaR1C1 = "" Range("I32").Select ActiveCell.FormulaR1C1 = "" Range("J32").Select ActiveCell.FormulaR1C1 = "" Range("K32").Select ActiveCell.FormulaR1C1 = "" Range("L32").Select ActiveCell.FormulaR1C1 = "" Range("L33").Select ActiveCell.FormulaR1C1 = "" Range("K33").Select ActiveCell.FormulaR1C1 = "" Range("J33").Select ActiveCell.FormulaR1C1 = "" Range("I33").Select ActiveCell.FormulaR1C1 = "" Range("H33").Select ActiveCell.FormulaR1C1 = "" Range("H34").Select ActiveCell.FormulaR1C1 = "" Range("I34").Select ActiveCell.FormulaR1C1 = "" Range("J34").Select ActiveCell.FormulaR1C1 = "" Range("K34").Select ActiveCell.FormulaR1C1 = "" Range("L34").Select ActiveCell.FormulaR1C1 = "" Range("L35").Select ActiveCell.FormulaR1C1 = "" Range("K35").Select ActiveCell.FormulaR1C1 = "" Range("J35").Select ActiveCell.FormulaR1C1 = "" Range("I35").Select ActiveCell.FormulaR1C1 = "" Range("H35").Select ActiveCell.FormulaR1C1 = "" Range("H38").Select End Sub End Sub |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
okay so this is what I got...
Private Sub CommandButton1_Click() Sub Clear() Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents End Sub End Sub but it's still giving me... Compile Error: (expected end sub) and has this: Private Sub CommandButton1_Click() in yellow. "Norman Jones" wrote: Hi Chris, Your 98 lines of code can be condensed to a single instruction Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents Notr that your code had two headers: Private Sub CommandButton1_Click() Sub Clear() and two closing lines: End Sub End Sub Additionally, it is not necessary to select a range in order to clear its contents and it is not necessary to clear the cells individually. --- Regards, Norman "Chris" wrote in message ... there you go... have at it... Private Sub CommandButton1_Click() Sub Clear() ' ' Clear Macro ' Macro recorded 4/17/2007 by marrech ' ' Range("F18:F19").Select ActiveCell.FormulaR1C1 = "" Range("G18:G19").Select ActiveCell.FormulaR1C1 = "" Range("H18:H19").Select ActiveCell.FormulaR1C1 = "" Range("I18:I19").Select ActiveCell.FormulaR1C1 = "" Range("J18:J19").Select ActiveCell.FormulaR1C1 = "" Range("F27:F28").Select ActiveCell.FormulaR1C1 = "" Range("G27:G28").Select ActiveCell.FormulaR1C1 = "" Range("H27:H28").Select ActiveCell.FormulaR1C1 = "" Range("I27:I28").Select ActiveCell.FormulaR1C1 = "" Range("J27:J28").Select ActiveCell.FormulaR1C1 = "" Range("C16").Select ActiveCell.FormulaR1C1 = "" Range("C17").Select ActiveCell.FormulaR1C1 = "" Range("C18").Select ActiveCell.FormulaR1C1 = "" Range("C19").Select ActiveCell.FormulaR1C1 = "" Range("C20").Select ActiveCell.FormulaR1C1 = "" Range("C21").Select ActiveCell.FormulaR1C1 = "" Range("C22").Select ActiveCell.FormulaR1C1 = "" Range("C23").Select ActiveCell.FormulaR1C1 = "" Range("C24").Select ActiveCell.FormulaR1C1 = "" Range("C25").Select ActiveCell.FormulaR1C1 = "" Range("C26").Select ActiveCell.FormulaR1C1 = "" Range("C27").Select ActiveCell.FormulaR1C1 = "" Range("C28").Select ActiveCell.FormulaR1C1 = "" Range("C29").Select ActiveCell.FormulaR1C1 = "" Range("C30").Select ActiveCell.FormulaR1C1 = "" Range("D32").Select ActiveCell.FormulaR1C1 = "" Range("D33").Select ActiveCell.FormulaR1C1 = "" Range("D34").Select ActiveCell.FormulaR1C1 = "" Range("H32").Select ActiveCell.FormulaR1C1 = "" Range("I32").Select ActiveCell.FormulaR1C1 = "" Range("J32").Select ActiveCell.FormulaR1C1 = "" Range("K32").Select ActiveCell.FormulaR1C1 = "" Range("L32").Select ActiveCell.FormulaR1C1 = "" Range("L33").Select ActiveCell.FormulaR1C1 = "" Range("K33").Select ActiveCell.FormulaR1C1 = "" Range("J33").Select ActiveCell.FormulaR1C1 = "" Range("I33").Select ActiveCell.FormulaR1C1 = "" Range("H33").Select ActiveCell.FormulaR1C1 = "" Range("H34").Select ActiveCell.FormulaR1C1 = "" Range("I34").Select ActiveCell.FormulaR1C1 = "" Range("J34").Select ActiveCell.FormulaR1C1 = "" Range("K34").Select ActiveCell.FormulaR1C1 = "" Range("L34").Select ActiveCell.FormulaR1C1 = "" Range("L35").Select ActiveCell.FormulaR1C1 = "" Range("K35").Select ActiveCell.FormulaR1C1 = "" Range("J35").Select ActiveCell.FormulaR1C1 = "" Range("I35").Select ActiveCell.FormulaR1C1 = "" Range("H35").Select ActiveCell.FormulaR1C1 = "" Range("H38").Select End Sub End Sub |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
Hi Chris,
Di you see my comment: Notr that your code had two headers: Private Sub CommandButton1_Click() Sub Clear() and two closing lines: End Sub End Sub Try: '============= Private Sub CommandButton1_Click() Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents End Sub '<<============= --- Regards, Norman Microsoft Excel MVP "Chris" wrote in message ... okay so this is what I got... Private Sub CommandButton1_Click() Sub Clear() Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents End Sub End Sub but it's still giving me... Compile Error: (expected end sub) and has this: Private Sub CommandButton1_Click() in yellow. "Norman Jones" wrote: Hi Chris, Your 98 lines of code can be condensed to a single instruction Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents Notr that your code had two headers: Private Sub CommandButton1_Click() Sub Clear() and two closing lines: End Sub End Sub Additionally, it is not necessary to select a range in order to clear its contents and it is not necessary to clear the cells individually. --- Regards, Norman "Chris" wrote in message ... there you go... have at it... Private Sub CommandButton1_Click() Sub Clear() ' ' Clear Macro ' Macro recorded 4/17/2007 by marrech ' ' Range("F18:F19").Select ActiveCell.FormulaR1C1 = "" Range("G18:G19").Select ActiveCell.FormulaR1C1 = "" Range("H18:H19").Select ActiveCell.FormulaR1C1 = "" Range("I18:I19").Select ActiveCell.FormulaR1C1 = "" Range("J18:J19").Select ActiveCell.FormulaR1C1 = "" Range("F27:F28").Select ActiveCell.FormulaR1C1 = "" Range("G27:G28").Select ActiveCell.FormulaR1C1 = "" Range("H27:H28").Select ActiveCell.FormulaR1C1 = "" Range("I27:I28").Select ActiveCell.FormulaR1C1 = "" Range("J27:J28").Select ActiveCell.FormulaR1C1 = "" Range("C16").Select ActiveCell.FormulaR1C1 = "" Range("C17").Select ActiveCell.FormulaR1C1 = "" Range("C18").Select ActiveCell.FormulaR1C1 = "" Range("C19").Select ActiveCell.FormulaR1C1 = "" Range("C20").Select ActiveCell.FormulaR1C1 = "" Range("C21").Select ActiveCell.FormulaR1C1 = "" Range("C22").Select ActiveCell.FormulaR1C1 = "" Range("C23").Select ActiveCell.FormulaR1C1 = "" Range("C24").Select ActiveCell.FormulaR1C1 = "" Range("C25").Select ActiveCell.FormulaR1C1 = "" Range("C26").Select ActiveCell.FormulaR1C1 = "" Range("C27").Select ActiveCell.FormulaR1C1 = "" Range("C28").Select ActiveCell.FormulaR1C1 = "" Range("C29").Select ActiveCell.FormulaR1C1 = "" Range("C30").Select ActiveCell.FormulaR1C1 = "" Range("D32").Select ActiveCell.FormulaR1C1 = "" Range("D33").Select ActiveCell.FormulaR1C1 = "" Range("D34").Select ActiveCell.FormulaR1C1 = "" Range("H32").Select ActiveCell.FormulaR1C1 = "" Range("I32").Select ActiveCell.FormulaR1C1 = "" Range("J32").Select ActiveCell.FormulaR1C1 = "" Range("K32").Select ActiveCell.FormulaR1C1 = "" Range("L32").Select ActiveCell.FormulaR1C1 = "" Range("L33").Select ActiveCell.FormulaR1C1 = "" Range("K33").Select ActiveCell.FormulaR1C1 = "" Range("J33").Select ActiveCell.FormulaR1C1 = "" Range("I33").Select ActiveCell.FormulaR1C1 = "" Range("H33").Select ActiveCell.FormulaR1C1 = "" Range("H34").Select ActiveCell.FormulaR1C1 = "" Range("I34").Select ActiveCell.FormulaR1C1 = "" Range("J34").Select ActiveCell.FormulaR1C1 = "" Range("K34").Select ActiveCell.FormulaR1C1 = "" Range("L34").Select ActiveCell.FormulaR1C1 = "" Range("L35").Select ActiveCell.FormulaR1C1 = "" Range("K35").Select ActiveCell.FormulaR1C1 = "" Range("J35").Select ActiveCell.FormulaR1C1 = "" Range("I35").Select ActiveCell.FormulaR1C1 = "" Range("H35").Select ActiveCell.FormulaR1C1 = "" Range("H38").Select End Sub End Sub |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro's
yeah... i did.. .sorry.... thank you.. it's working great...
I am going to enroll in a class the teaches excel.. i use it sooo much now and these dumb books don't seem to teach anything important or at least what I need to know... "Norman Jones" wrote: Hi Chris, Di you see my comment: Notr that your code had two headers: Private Sub CommandButton1_Click() Sub Clear() and two closing lines: End Sub End Sub Try: '============= Private Sub CommandButton1_Click() Range("F18:J19, F27:J28, C16:C30, D32:D34, H32:L35"). _ ClearContents End Sub '<<============= --- Regards, Norman Microsoft Excel MVP |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro's | Excel Discussion (Misc queries) | |||
Hide Macro's in Toolbar / Macro's list | Excel Discussion (Misc queries) | |||
Macro's | Excel Worksheet Functions | |||
Macro's | Excel Discussion (Misc queries) | |||
macro's | Excel Worksheet Functions |