EXCEL 비정규 데이터를 드래그하여 방정식을 자동으로 채울 수 없는 스크립트 방법

5638 단어 EXCELVBS
우선, EEPROM, FLASH 등 check 작업을 할 때 데이터 구조 블록이 16의 정수 배가 아닌 것을 만날 수 있으며, 이때 EXCEL에서 제공하는 드래그식 방법으로 공식을 자동으로 채울 수 없기 때문에 수동으로 작성할 수 있습니다.350줄은 괜찮지만 수천 수만 줄의 데이터 변환 공식에 대해 말하자면 틀림없이 효율이 크게 떨어질 것이다.나중에 이런 문제가 발생할 때 참고할 수 있도록 스크립트 코드를 백업합니다.

dim row
dim colum, col
dim index
dim str, calStr, colLabel
dim colName
dim resRow, resCol
dim srcRow, srcCol
dim rngStr, rngStr1, rngStr2
dim indexArray, i
dim mainStr(407)


colName = "CDEFGHIJKLMNOPQR"

REM str = ""
REM for row = 14 to 246 step 1
    REM for colum = 1 to 16 step 2
        REM str = str&"="&mid(colName, colum, 1)&row&"+"&mid(colName, (colum+1),1)&row&"*256"&vbCrlf
    REM next
REM next


REM calStr = ""
REM '=if((),(),()) & 
REM for row = 900 to 949 step 1
    REM for colum = 1 to 14 step 1
        REM colLabel = mid(colName, colum, 1)& row
        REM if(colum = 1)then
            REM calStr = calStr & "="
        REM End If
        REM calStr = calStr & "if((HEX2DEC(" & colLabel & ")<>0), CHAR(HEX2DEC(" & colLabel & ")), " & chr(34) & chr(34) & ")" & " & "
    REM next
    REM calStr = mid(calStr, 1, Len(calStr)-3)
    REM calStr = calStr & vbCrlf
REM next


calStr = ""
col = 13 ' "O"
srcRow = 218
indexArray = 0
For row = 1 To 400 Step 1
    If col > 16 Then
        col = 1
        srcRow = srcRow + 1
    End If
    rngStr = Mid(colName, col, 1) & srcRow
    mainStr(indexArray) = rngStr
    indexArray = indexArray + 1
    col = col + 1
Next

calStr = ""
colName = " YAGAO"
i = 0
for row = 219 to 251 step 2
    calStr = calStr & "=HEX2DEC(" & mainStr(i) & ")+Hex2Dec(" & mainStr(i+1) & ")*256" & space(136-33) & _
                      "=Hex2Dec(" & mainStr(i+8) & ")+Hex2Dec(" & mainStr(i+9) & ")*256" & space(136-33) & _
                      "=Hex2Dec(" & mainStr(i+16) & ")+Hex2Dec(" & mainStr(i+17) & ")*256" & vbCrlf
                      
    calStr = calStr & "=" & chr(34) & "20" & chr(34) & " & HEX2DEC(" & mainStr(i+2) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+3) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+4) & ") & " & chr(34) & " " & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+5) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+6) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+7) & ")    " & _                     
                      "=" & chr(34) & "20" & chr(34) & " & HEX2DEC(" & mainStr(i+10) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+11) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+12) & ") & " & chr(34) & " " & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+13) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+14) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+15) & ")    " & _
                      "=" & chr(34) & "20" & chr(34) & " & HEX2DEC(" & mainStr(i+18) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+19) & ") & " & chr(34) & "-" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+20) & ") & " & chr(34) & " " & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+21) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+22) & ") & " & chr(34) & ":" & chr(34) & _
                                                       " & Hex2dec(" & mainStr(i+23) & ")" & vbCrlf
    i = i + 24
next

set fs=createobject("scripting.filesystemobject")
set f =fs.opentextfile("e:\text.txt",8)
f.writeblanklines(1)
f.writeline calStr
f.close
set f =nothing
set fs=nothing

좋은 웹페이지 즐겨찾기