1. Okay. You have not posted an example of any input file so it's hit-and-miss as to what will or will not work. Test this, no allowance is made for filenames containing spaces.:@echo off cls setlocal enabledelayedexpansion if exist output.csv del output.csv dir /a-d /b Data_*.csv>dirfiles.txt for /Read more

    Okay. You have not posted an example of any input file so it’s hit-and-miss as to what will or will not work. Test this, no allowance is made for filenames containing spaces.:

    @echo off
    cls
    setlocal enabledelayedexpansion
    
    if exist output.csv del output.csv
    
    dir /a-d /b Data_*.csv>dirfiles.txt
    
    for /f "tokens=*" %%1 in (dirfiles.txt) do (
        set /p header=<%%1
        echo !header!>output.csv
    )
    
    for /f "tokens=*" %%1 in (dirfiles.txt) do (
            more +1 %%1>>output.csv
       )
    
    del dirfiles.txt
    

    Please come back & tell us if your problem is resolved.

    See less
    • 0
  2. I actually played around with this and got it working by putting in an exclamation point around the variable while inside the for loop. Thanks all for your time. This forum was the only way I got this far!!! Here's the CSV and the numeric CPU load is what I am averaging.Node,LoadPercentage,MaxClockSRead more

    I actually played around with this and got it working by putting in an exclamation point around the variable while inside the for loop. Thanks all for your time. This forum was the only way I got this far!!!

    Here’s the CSV and the numeric CPU load is what I am averaging.
    Node,LoadPercentage,MaxClockSpeed
    batphonevm,21,2200
    Node,LoadPercentage,MaxClockSpeed
    batphonevm,4,2200
    Node,LoadPercentage,MaxClockSpeed
    batphonevm,33,2200
    Node,LoadPercentage,MaxClockSpeed
    batphonevm,24,2200

    And here’s the new for loop so everyone can see.
    REM set globals
    set /a counter=0
    set /a TOTALLOAD=0

    for /F “tokens=1,2,3 delims=,” %%m in (‘findstr /v “Node,LoadPercentage,MaxClockSpeed” temp.txt’) do (
    set localMachine=%%m
    set /a CPUload=%%n
    set /a CPUspeed=%%o
    set /a counter+=1
    set /a TOTALLOAD=!TOTALLOAD!+!CPUload!

    )

    del temp.txt
    echo totalLoad is: %totalLoad%
    set /a averageLoad=%totalLoad% / %counter%
    echo Average load is: %averageLoad%
    echo %date%,%averageLoad% >> %node%\dailyCPUAverage.txt
    REM del %node%\cpuload.txt

    See less
    • 0
  3. might try this modification ( [ ] are just for reference): [echo prompt n>>ftpcmd.txt] for /f "tokens=* delims=" %%a in ('dir /b /s /ad') do echo mput %%a\*.html>> ftpcmd.txt [echo bye >> ftpcmd.txt] alot depends on if you want local dir. structure mirrored on remote.

    might try this modification ( [ ] are just for reference):
    [echo prompt n>>ftpcmd.txt]
    for /f “tokens=* delims=” %%a in (‘dir /b /s /ad’) do echo mput %%a\*.html>> ftpcmd.txt
    [echo bye >> ftpcmd.txt]
    alot depends on if you want local dir. structure mirrored on remote.

    See less
    • 0
  4. Have you considered adding a PlayAgain: label and a GoTo PlayAgain instruction?Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.

    Have you considered adding a PlayAgain: label and a GoTo PlayAgain instruction?

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    See less
    • 0
  5. Are you sure that that is the code that you are actually running?When I try it it crashes my Excel 2010 application completely and I think I can see why. However, before I explain why I think the code is not working, I have to ask a question. What are you trying to do with this line:If Target.Row AnRead more

    Are you sure that that is the code that you are actually running?

    When I try it it crashes my Excel 2010 application completely and I think I can see why. However, before I explain why I think the code is not working, I have to ask a question.

    What are you trying to do with this line:

    If Target.Row And Target.Cells.Count = 1 Then

    I understand that If Target.Cells.Count = 1 is used to make sure that only one cell has changed, but I don’t know what If Target.Row is used for. As far as I know, If Target.Row will always return True because Target.Row is going to return a number. Since VBA will consider any number that is not 0 to be “Not False”, and therefore True, I don’t think your are accomplishing anything with If Target.Row. Am I missing something subtle? I’m always willng to learn. 😉

    OK, that said, let’s look at your Worksheet_Change code.

    Debugging Worksheet_Change macros can be a pain since they don’t easily allow you to Single Step through the code like a regular macro does. The trick is to force an syntax error which stops the code as soon as it is triggered allowing you to correct the error and then use the Single Step feature.

    Try this:

    Edit your code so that If becomes Iff. Ignore the red line error indication for now.

    Private Sub Worksheet_Change(ByVal Target As Range)
     Iff Target.Row And Target.Cells.Count = 1 Then
         Range("Q" & Target.Row) = Date
     End If
    End Sub

    When you make a change to your spreadsheet, the code should throw up a Syntax Error while leaving the first line Private Sub Worksheet_Change(ByVal Target As Range) highlighted in yellow and the Iff line highlighted as an error.

    Now, delete the extra F in that line. This will leave you in Debug mode and you can use F8 to single step through the code.

    Pressing F8 continually should show you what the problem is. When the code puts the Date in Column Q, that is considered a change to the worksheet, which triggers the code to run again, putting the Date in Column Q which is considered a change to the worksheet, which triggers the code to run again, putting the Date in Column Q which is considered a change to the worksheet, which triggers the code to run again, putting the Date in Column Q which… and on and on forever.

    On the system I am using right now, in which Excel runs as a cloud based application, I believe the application crashes because it can’t keep up with the rapidly repeating requests to keep putting the Date in the same cell. It make act differently when Excel is running on your local machine, but I can’t test that right now. In any case, I believe that to be the problem.

    One way to deal with that issue is to disable Events until after the Date has been placed in the cell and then enable Events before exiting the code. That way the change doesn’t trigger the Event code to run again and again and again.

    When I use this code, I don’t have any problems, even when using a Data Validation drop down:

    Private Sub Worksheet_Change(ByVal Target As Range)
      Application.EnableEvents = False
        If Target.Row And Target.Cells.Count = 1 Then
           Range("Q" & Target.Row) = Date
        End If
      Application.EnableEvents = True
    End Sub

    One key point: If your code crashes or you stop the code after…

    Application.EnableEvents = False

    but before:

    Application.EnableEvents = True

    …Events will remain disabled and no event driven code will run. You can re-enable Events in 3 ways:

    1 – Use a macro to enable Events:

    Sub Enable_Events()
      Application.EnableEvents = True
    End Sub

    2 – Open the Immediate window in the VBA editor, paste in this line and hit Enter:

    Application.EnableEvents = True

    3 – Quit Excel and reopen the application.

    One other option that can be employed is to check and see what Column was changed and only run the code if the change was made to one of the Columns that you want to trigger the code. (A, B, C, D OR N). When the code puts the Date in Column Q it will still retrigger the code but since the change was not made to one of the desired columns, the code will quit. As your code is written now, the date is going to be placed in Column Q regardless of what Column was changed.

    Click Here Before Posting Data or VBA Code —> How To Post Data or Code.

    See less
    • 0
  6. As it turns out, the solution is to use just =(A1/B2) format and forget about =quotient function.

    As it turns out, the solution is to use just =(A1/B2) format and forget about =quotient function.

    See less
    • 0
  7. If you have the means to install it again, uninstall & reinstall might fix it. Alternatively you could use System Restore to a date before it went wrong, if it was recent: Control Panel > System > System Protection.

    If you have the means to install it again, uninstall & reinstall might fix it.
    Alternatively you could use System Restore to a date before it went wrong, if it was recent:
    Control Panel > System > System Protection.

    See less
    • 0
  8. Did you disable SpyBot Immunize then run the repair again from square one after restarting the computer?It is odd that SpyBot Immunize affected it. It's years since I used it but all it used to do was block you from accessing bad websites. If you are running that wretched "T-Timer" facility then surRead more

    Did you disable SpyBot Immunize then run the repair again from square one after restarting the computer?

    It is odd that SpyBot Immunize affected it. It’s years since I used it but all it used to do was block you from accessing bad websites. If you are running that wretched “T-Timer” facility then sure, it can and always has had the potential to wreck anything so most folk turn it off.

    Always pop back and let us know the outcome – thanks

    message edited by Derek

    See less
    • 0
  9. Click Send/Receive. Notice that when Outlook is set to Work Offline, the button is highlighted. Click Work Offline to return to working online. After you reconnect to the server, the Work Offline button has a plain background:

    Click Send/Receive. Notice that when Outlook is set to Work Offline, the button is highlighted.
    Click Work Offline to return to working online. After you reconnect to the server, the Work Offline button has a plain background:

    See less
    • 0
  10. Right-Click the sheet tab for the sheet with the drop down, choose View Code and paste this code in:Private Sub Worksheet_Change(ByVal Target As Range) If Target.Address = "$H$5" Then fname = Range("H7") & "-" & Range("H5") ActiveWorkbook.SaveAs Filename:=fname End If End SubWhenever H5 chanRead more

    Right-Click the sheet tab for the sheet with the drop down, choose View Code and paste this code in:

    Private Sub Worksheet_Change(ByVal Target As Range)
     If Target.Address = "$H$5" Then
      fname = Range("H7") & "-" & Range("H5")
      ActiveWorkbook.SaveAs Filename:=fname
     End If
    End Sub

    Whenever H5 changes, the variable fname will be set to the values in H7 and H5 with a dash in between, as in your example.

    The file will then be saved using fname as the file name.

    As written, Excel will ask you if you want to overwrite the file if that filename already exists, but that can be dealt with if need be.

    Let me know if this works for you.

    See less
    • 0