Skip to content
컴퓨터잡담
2011.09.25 21:34

ExCEL VBA) 파일을 열지않고 값 읽어오기

조회 수 20215 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

ExCEL VBA) 파일을 열지않고 값 읽어오기

 

Option Explicit

Function ReadValue(Path, File, sht, Rng) As Variant
    Dim Msg As String
    Dim strTemp As String
   
    If Trim(Right(Path, 1)) <> "\" Then Path = Path & "\"
    If Dir(Path & File) = "" Then
        ReadValue = "해당 파일이 없습니다"
        Exit Function
    End If
    Msg = "'" & Path & "[" & File & "]" & sht & "'!" & Range(Rng).Range("a1").Address(, , xlR1C1)
    ReadValue = ExecuteExcel4Macro(Msg)
End Function

Sub CallReadValue()
    Dim strPath As String
    Dim strFile As String
    Dim strSheet As String
    Dim strAddress As String
    Dim sht As Worksheet
    Dim r As Long
    Dim c As Integer
   
    Application.ScreenUpdating = True
    Set sht = Worksheets.Add
    ActiveWindow.DisplayGridlines = False
    strPath = ThisWorkbook.Path
    strFile = "지점별실적.xls"
    strSheet = "Sheet1"
   
    For r = 1 To 11
        For c = 1 To 5
            strAddress = Cells(r, c).Address
            If ReadValue(strPath, strFile, strSheet, strAddress) = 0 Then Exit For
            Cells(r, c) = ReadValue(strPath, strFile, strSheet, strAddress)
        Next c
    Next r
   
    Selection.AutoFormat Format:=xlRangeAutoFormatList1, Number:=True, Font:= _
        True, Alignment:=True, Border:=True, Pattern:=True, Width:=True
    Rows("1:2").Insert shift:=xlDown
   
    With ActiveCell
        ActiveSheet.Buttons.Add(.Left, .Top, .Width * 2, .Height).Select
        With Selection
            .Caption = "<<돌아가기"
            .OnAction = "GoBack"
        End With
    End With
    Range("a1").Select
    MsgBox "자료를 모두 읽어들였습니다", vbInformation, "작업 종료//Exceller"
End Sub

Sub GoBack()
    Application.Goto Sheets("Preface").Range("a1"), True
End Sub

로그인 후 댓글쓰기가 가능합니다.

?

List of Articles
번호 분류 제목 날짜 조회 수
617 [Docs]스프레드시트 스프레드시트 api append & update php 셀 내용 수정 4 2016.08.08 5314
616 [Docs]스프레드시트 스프레드 웹게시로 불러오기 1 2016.06.24 4725
615 WindowsTip 스윙 브라우저와 크롬 브라우저 비교 file 2013.02.14 8117
614 WindowsTip 스마트폰으로 오실로스코프 사용하기(App:OsciPrime Oscilloscope Legacy) file 2013.12.27 23302
613 컴퓨터잡담 스누피 고스트 file 2010.10.01 6031
612 Server 슈퍼캐시에서 .htaccess 이부분 제거해야 하나? 2016.11.23 4525
611 [Docs]스프레드시트 쇼킹한 웹 긁어오기 2014.11.11 3903
610 컴퓨터잡담 셀에 현재 날짜와 시간 삽입 2010.06.15 10276
609 컴퓨터잡담 서비스팩3 설치 후 Client Session manager 문제, SM00905 오류 해결방법 1 2 2010.11.01 14407
608 컴퓨터잡담 서버에 SSD 교체 작업을 해야되나? 2010.04.20 6521
607 컴퓨터잡담 서버 해킹 당하다~ 1 6 2009.11.20 15662
606 Server 서버 최적화 시키기(APACHE, PHP, MYSQL, XE 압축&캐싱&버퍼) 3 file 2016.03.18 6239
605 Server 서버 부하상태 체크 file 2016.04.30 1709
604 Server 서버 다운시 알람 기능 사용방법(http ping port) file 2017.05.04 10364
603 컴퓨터잡담 서버 다운 원인 2015.12.10 558
602 WindowsTip 삼성노트북 NT300E5C-A15R 드라이버 2012.11.27 8814
601 컴퓨터잡담 삼성, 프로그래머들에게 스마트폰 콘텐츠 개발하고 싶게 만들어라. 2 2010.04.09 10989
600 컴퓨터잡담 삼성, LG 여! 스마트폰의 창작기술로 아이폰을 점령하라! 2011.09.03 3642
599 컴퓨터잡담 삼성 센스P30노트북 도스에서 USB 설정방법 2 file 2011.07.26 8641
598 컴퓨터잡담 사이트를 검색엔진에 등록하는 방법 1 2013.01.11 7031
Board Pagination Prev 1 ... 14 15 16 17 18 ... 46 Next
/ 46

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소