Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Search marco to update a table

I have a code that should:
Look through all worksheets for Gl numbers that match those in the first
sheet. Once it finds a number it needs to copy the adjecent amount in the
correct place in the first sheet. The code needs to work its way through the
whole work book which has many sheets. Also the tables may have gaps. None of
the tables can be filtered and it has to work using a macro (i.e. no cell
functions)

This is the code i have so far:

'Define function to find end of table
Function checklast() As Boolean
Selection.End(xlDown).Select
If ActiveCell.Address = "$A$65536" Then checklast = True Else
checklast = False
Exit Function
Worksheets(nx).Range(add).Select
End Function

Sub Macro2()
'Define Variables
Dim c As Object
Dim WS As Worksheet
Dim x As Integer
Dim gl As Integer
Dim amt As Integer
Dim add As String
Dim nx As String

'Loop through each worksheet except first one
For Each WS In ActiveWorkbook.Sheets
WS.Activate
If WS.Name < "Sheet1" Then
GoSub Process_data
End If
'MsgBox "Looking at the sheet named: " & WS.Name
Next WS

'Check if cell in current worksheet contains a value
Process_data:
x = 1
Do
If WS.Cells(x, 1).Value < "" Then
gl = WS.Cells(x, 1).Value
amt = WS.Cells(x, 2).Value
nx = WS.Name
add = WS.Cells(x, 1).Address
GoSub Process_detail
End If
x = x + 1
Loop Until checklast() = True
Return

'Check if cell in first sheet contains a value equal to gl
'If one is found paste amt in adjecent cell
Process_detail:
Worksheets("Sheet1").Activate
With Worksheets("Sheet1").Range("A1:A100")
Set c = .Find(gl, LookIn:=xlValues)
If Not c Is Nothing Then
.Range(c.Address).Activate
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = amt
End If
End With
Return

End Sub

Can anyone help?
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
Using a marco to update my spreadsheet. [email protected] Excel Programming 2 September 14th 06 04:57 PM
marco for a pivot table and expansion Macro for a Pivot Table Excel Programming 0 December 23rd 05 06:51 PM
Pivot table marco problem! matthewwookie[_3_] Excel Programming 0 September 26th 05 09:31 AM
marco after selection in PV table Dennis Cheung[_2_] Excel Programming 9 May 12th 05 03:45 PM
Marco: Pivot Table Tim Excel Programming 2 April 21st 05 04:53 AM


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

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

About Us

"It's about Microsoft Excel"