Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba - need simple function to delete ranges
hi,
i'm very new to vba for excel.. working with very easy examples. wondering if anyone can help me with a repetitive task. i have data comming in to various columns. at some data there is a #NA, i'd like to delete everything in that column after that #NA, and then move on to the next column and repeat the task. thanks, thomas |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba - need simple function to delete ranges
this is not an elegant solution for which you have to wait solution from
MVPs meanwhile copy your data in another file and test this code and see whether this is what ou want. Public Sub test() On Error GoTo line1 Dim cell As Range For Each cell In Range("a1:F1") cell.Activate Cells.Find(what:="#n/a").Activate ActiveCell.EntireColumn.Delete Next cell line1: End Sub tom g <tom wrote in message ... hi, i'm very new to vba for excel.. working with very easy examples. wondering if anyone can help me with a repetitive task. i have data comming in to various columns. at some data there is a #NA, i'd like to delete everything in that column after that #NA, and then move on to the next column and repeat the task. thanks, thomas |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba - need simple function to delete ranges
Thomas,
Try this Public Sub test() Dim cell As Range Dim crows As Long For Each cell In ActiveSheet.UsedRange If WorksheetFunction.IsError(cell.Value) Then crows = Cells(Rows.Count, cell.Column).End(xlUp).Row Range(Cells(cell.Row, cell.Column), Cells(crows, cell.Column)).ClearContents End If Next cell End Sub -- HTH RP (remove nothere from the email address if mailing direct) "R.VENKATARAMAN" &&& wrote in message ... this is not an elegant solution for which you have to wait solution from MVPs meanwhile copy your data in another file and test this code and see whether this is what ou want. Public Sub test() On Error GoTo line1 Dim cell As Range For Each cell In Range("a1:F1") cell.Activate Cells.Find(what:="#n/a").Activate ActiveCell.EntireColumn.Delete Next cell line1: End Sub tom g <tom wrote in message ... hi, i'm very new to vba for excel.. working with very easy examples. wondering if anyone can help me with a repetitive task. i have data comming in to various columns. at some data there is a #NA, i'd like to delete everything in that column after that #NA, and then move on to the next column and repeat the task. thanks, thomas |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
vba - need simple function to delete ranges
thanks guys that helps.. the only problem is that its not a function error.
its hard typed #NA ... it could easily be the word 'WRONG' as well. how would i define that. thanks, thomas "tom g" wrote: hi, i'm very new to vba for excel.. working with very easy examples. wondering if anyone can help me with a repetitive task. i have data comming in to various columns. at some data there is a #NA, i'd like to delete everything in that column after that #NA, and then move on to the next column and repeat the task. thanks, thomas |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Delete unnecessary Named Ranges | Excel Discussion (Misc queries) | |||
Simple problem, simple formula, no FUNCTION ! | Excel Worksheet Functions | |||
Allow user to delete cell ranges? | Excel Discussion (Misc queries) | |||
Named ranges interfere with simple formulas | Excel Discussion (Misc queries) | |||
delete or edit named dell ranges | Excel Discussion (Misc queries) |