Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default writing a vba code for a simple function

Hi

I have just started using VBA from today and I am slowly getting the grasp of it. For the time being I am supposed to write a code to execute a certain function. Let me break down the scenario. I have a table with some names (which is linked to a different worksheet). if instead of the names, an error message comes up, I want to retrieve all the rows with the errors and transfer these messages to a different worksheet showing the errors.

I was thinking about maybe using strings and conditional commands but since I just started using VBA I cant quite figure out the picture as to how to go about writing the code. Could you please help me out? I would appreciate it

EggHeadCafe - Software Developer Portal of Choice
Silverlight 3 Bing API: A Related Links Widget
http://www.eggheadcafe.com/tutorials...-bing-api.aspx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default writing a vba code for a simple function

In the errors are in column A of the activesheet, and you want to transfer the errors to a sheet
named Errors, then you could use


Sub Macro1()
Dim myC As Range
Dim myR As Range
Dim myS As Worksheet
Dim myD As Worksheet

Set myS = ActiveSheet
Set myD = Worksheets("Errors")

myD.Activate

Set myR = Intersect(myS.Range("A:A"), myS.UsedRange)
For Each myC In myR.SpecialCells(xlCellTypeFormulas, 16)
myC.EntireRow.Cut
myD.Cells(Rows.Count, 1).End(xlUp)(2).EntireRow.Select
myD.Paste
Next myC

myR.SpecialCells(xlCellTypeBlanks).EntireRow.Delet e
End Sub

HTH,
Bernie
MS Excel MVP


<niloy parvaz wrote in message ...
Hi

I have just started using VBA from today and I am slowly getting the grasp of it. For the time
being I am supposed to write a code to execute a certain function. Let me break down the scenario.
I have a table with some names (which is linked to a different worksheet). if instead of the
names, an error message comes up, I want to retrieve all the rows with the errors and transfer
these messages to a different worksheet showing the errors.

I was thinking about maybe using strings and conditional commands but since I just started using
VBA I cant quite figure out the picture as to how to go about writing the code. Could you please
help me out? I would appreciate it

EggHeadCafe - Software Developer Portal of Choice
Silverlight 3 Bing API: A Related Links Widget
http://www.eggheadcafe.com/tutorials...-bing-api.aspx



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default writing a vba code for a simple function

Try something like this


Set MyErrors = Sheets(1).Cells.SpecialCells( _
xlCellTypeFormulas, xlErrors).EntireRow
MyErrors.Copy destination:=Sheets(2).Cells

"niloy parvaz" wrote:

Hi

I have just started using VBA from today and I am slowly getting the grasp of it. For the time being I am supposed to write a code to execute a certain function. Let me break down the scenario. I have a table with some names (which is linked to a different worksheet). if instead of the names, an error message comes up, I want to retrieve all the rows with the errors and transfer these messages to a different worksheet showing the errors.

I was thinking about maybe using strings and conditional commands but since I just started using VBA I cant quite figure out the picture as to how to go about writing the code. Could you please help me out? I would appreciate it

EggHeadCafe - Software Developer Portal of Choice
Silverlight 3 Bing API: A Related Links Widget
http://www.eggheadcafe.com/tutorials...-bing-api.aspx
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Writing and erasing code with code bobbo Excel Programming 4 October 11th 06 08:28 PM
Is there a simple function code to do it?. A[_4_] Excel Programming 4 October 5th 06 06:02 PM
Function for simple code goeppngr Excel Programming 1 February 28th 06 04:14 PM
Writing a simple macro or formula Robin Excel Programming 2 January 28th 06 11:10 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"