Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Concatenating two variable fields into a static length text field | Excel Worksheet Functions | |||
STATIC VARIABLE NOT AVAILABLE IN ANOTHER MODULE | Excel Discussion (Misc queries) | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
NOT static variable problem | Excel Programming | |||
Static Variable | Excel Programming |