zombie45
zombie's dev story
zombie45

공지사항

  • 분류 전체보기
    • iPhone
    • Study

인기 글

최근 댓글

최근 글

티스토리

반응형

블로그 메뉴

  • 홈
  • 태그
  • 미디어로그
  • 위치로그
  • 방명록
  • 글쓰기
전체 방문자
오늘
어제

태그

  • caching
  • nextFocus
  • 큰폴더
  • 큰파일
  • flutter_localizations
  • 자동배포
  • cache
  • Box2d cocos2dx cocos2d-x
  • 카카오 로그인
  • actions
  • 안드로이드
  • TextInputAction
  • textformfield
  • Animtaion
  • flutter l10n helper
  • l10nization
  • cocoapods-binary-cache
  • jks
  • Flutter
  • 오블완
  • FocusScope
  • CI/CD
  • appDelegate
  • 티스토리챌린지
  • Nodejs node express expressjs
  • code spell checker
  • cspell
  • intl
  • UIViewController
  • android_key_hash
hELLO · Designed By 정상우.
zombie45

zombie's dev story

Study

macro 9/24

2013. 9. 24. 16:39
Sub table99()
    Dim inputRow, outputRow As Integer
    Dim fromSheet, toSheet As Worksheet
    Dim wsSetup As Worksheet
    Dim i, j As Integer
    Dim LR, NR As Long
    Dim col1, col2 As Long
    Dim fromCol, toCol As Long
    Dim strFind As String
    
    Set wsSetup = Excel.Worksheets("Setup")
    Set toSheet = Excel.Worksheets(wsSetup.Cells(6, 2).Value)
    strFind = wsSetup.Cells(14, 2).Value
    
    Set fromSheet = ThisWorkbook.Sheets(wsSetup.Cells(5, 2).Value)
    LR = toSheet.Range("C" & Rows.Count).End(xlUp).Row
    NR = fromSheet.Range("C" & Rows.Count).End(xlUp).Row
    
    col1 = fromSheet.UsedRange.Columns.Count
    col2 = toSheet.UsedRange.Columns.Count
    Do While 1
        If fromSheet.Cells(1, col1).Value = "" Then
            col1 = col1 - 1
        Else
            Exit Do
        End If
    Loop
    Do While 1
        If toSheet.Cells(2, col2).Value = "" Then
            col2 = col2 - 1
        Else
            Exit Do
        End If
    Loop
    
    
    For i = 1 To col1
        If LCase(fromSheet.Cells(1, i).Value) = LCase(strFind) Then
            fromCol = i
            Exit For
        End If
    Next i
    For i = 1 To col2
        If LCase(toSheet.Cells(2, i).Value) = LCase(strFind) Then
            toCol = i
            Exit For
        End If
    Next i


    inputRow = fromCol
    outputRow = toCol
    
    If LCase(toSheet.Cells(2, outputRow).Value) <> LCase(fromSheet.Cells(1, inputRow).Value) Then
        MsgBox (toSheet.Cells(2, outputRow).Value & "!=" & fromSheet.Cells(1, inputRow).Value)
    Else
    For j = 2 To NR
        fromSheet.Cells(j, 2).Interior.Color = RGB(255, 0, 6)
        For i = 2 To LR
            If fromSheet.Cells(j, 3).Value = toSheet.Cells(i, 3).Value Then
                fromSheet.Cells(j, 2).Value = i & "Row"
                fromSheet.Cells(j, 2).Interior.Color = RGB(255, 255, 255)
                toSheet.Cells(i, outputRow).Value = fromSheet.Cells(j, inputRow).Value
                Exit For
            End If
        Next i
    Next j

    End If

    MsgBox ("OK")
End Sub
'Sub numberrow()
'    Dim inputStr As String
'    inputStr = "GW"
'    MsgBox (Val(inputStr))
Sub Sample()
    Dim ColName As String
    
    ColName = "C"
    MsgBox (Range(ColName & 1).Column)
End Sub

Sub copy_table()
    Dim inputRow, outputRow As Integer
    Dim fromSheet, toSheet As Worksheet
    Dim wsSetup As Worksheet
    Dim LR, NR, col1, col2 As Integer
    Dim i, j As Integer
        
    Set wsSetup = Excel.Worksheets("Setup")
    Set fromSheet = Excel.Worksheets(wsSetup.Cells(5, 2).Value)
    Set toSheet = Excel.Worksheets(wsSetup.Cells(6, 2).Value)
    outputRow = Range(wsSetup.Cells(6, 3).Value & 1).Column
    inputRow = Range(wsSetup.Cells(5, 3).Value & 1).Column
    
    LR = toSheet.Range("C" & Rows.Count).End(xlUp).Row
    NR = fromSheet.Range("C" & Rows.Count).End(xlUp).Row

    If LCase(toSheet.Cells(2, outputRow).Value) <> LCase(fromSheet.Cells(1, inputRow).Value) Then
        MsgBox (toSheet.Cells(2, outputRow).Value & "!=" & fromSheet.Cells(1, inputRow).Value)
    Else
    For j = 2 To NR
        fromSheet.Cells(j, 2).Interior.Color = RGB(255, 0, 6)
        For i = 2 To LR
            If fromSheet.Cells(j, 3).Value = toSheet.Cells(i, 3).Value Then
                fromSheet.Cells(j, 2).Value = i & "Row"
                fromSheet.Cells(j, 2).Interior.Color = RGB(255, 255, 255)
                toSheet.Cells(i, outputRow).Value = fromSheet.Cells(j, inputRow).Value
                Exit For
            End If
        Next i
    Next j

    End If

    MsgBox ("OK")
End Sub


Sub DATAUPDATE()
    Dim ws As Worksheet, q As QueryTable
    
    For Each ws In ActiveWorkbook.Worksheets
        For Each q In ws.QueryTables
            q.Refresh (False)
        Next
    Next
End Sub

http://stackoverflow.com/questions/2538449/excel-macro-to-create-sheets

반응형

'Study' 카테고리의 다른 글

macro 9/26  (0) 2013.09.27
macro  (0) 2013.09.25
macro  (0) 2013.09.23
엑셀 메크로  (0) 2013.09.23
멀티 로칼 서버  (0) 2013.09.20
    'Study' 카테고리의 다른 글
    • macro 9/26
    • macro
    • macro
    • 엑셀 메크로
    zombie45
    zombie45
    잡다한 개발

    티스토리툴바