Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Static variable

Tom, thanks for the reply. Actually I found what I needed to deal with a
little farther down in the code. I need another counter to compensate for
the new rows. Thanks again!

"Tom Ogilvy" wrote:

Static means that copycntr retains the value after the macro terminates.

You can perhaps dispense with it using something like

Dim rng as Range
with Worksheets("Destination")
set rng = .cells(rows,count,"A").End(xlup)
if rng.row < 7 then
set rng.row = .Cells(7,1)
else
if not isempty(rng) then
set rng = rng.offset(2,0)
end if
end if
End With

SourceData.copy Destination:=rng

--
regards,
Tom Ogilvy


"cottage6" wrote in message
...
I'm not sure if this is enough of the code to explain my problem, but here
goes. This code was created by somebody else and I need to figure out

what
the static variable is doing. The macro allows users to retrieve multiple
files into 1 spreadsheet, and the data from each file appends under the

next.
The problem is the user sometimes adds a new row before retrieving the

next
file, and the new data is pasted over the top of the added row. I seems to

me
that I need to reset the copycntr variable if a new row is added, but I'm
totally confused. For example, the second file gets pasted into row 12
instead of row 7. Where in the code does copycntr know to change to row

12?
I hope I haven't made too much of a fool of myself; thanks for any help I

can
get!

Static copycntr
If Sheets("Store Data").Range("C7").Value = 0 Or Sheets("Store
Data").Range("C7").Value = "" _
Then copycntr = ""
If copycntr = "" Then
'If this is the first file being retrieved, the store number will be blank
'so set copycntr to 7, combine with "F", and copy the file data to cell

F7.
'First data row in Store Data sheet is Row 7.

copycntr = 7

End If




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
Concatenating two variable fields into a static length text field Young Programmer Lad Excel Worksheet Functions 2 April 17th 09 05:39 PM
STATIC VARIABLE NOT AVAILABLE IN ANOTHER MODULE CAPTGNVR Excel Discussion (Misc queries) 2 February 1st 07 07:30 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
NOT static variable problem Neal Zimm Excel Programming 4 April 22nd 05 04:38 PM
Static Variable Todd Huttenstine Excel Programming 7 May 7th 04 11:16 AM


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

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"