Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Microsoft Office [игнор отключен] [закрыт для гостей] / заполнение ячеек из списка в другой книге / 7 сообщений из 7, страница 1 из 1
30.06.2006, 16:27:22
    #33824802
Browzer
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
Excel 2003

Проблема следующая.
XLS документ лежит в сети.
Требуется на основании данных столбца этого документа сделать список
который затем использовать при заполнении локального XLS документа

То есть выбор значения ячейки из выпадаюшего списка.
Рылся в хелпе, там вроде как это реализуемо через назначение списку имени и функцию проверка -> список? но эксель пишет, что функция проверки для списка не работает шире чем в пределах документа.

Хелп?
...
Рейтинг: 0 / 0
30.06.2006, 18:35:51
    #33825171
Taranaga
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
Вообщето функция проверка не работает шире чем в пределах листа.
А чтобы вставить список на лист есть куча способов...
Если не вдаваться в макросы, можно получить список например с помощью запроса внешних данных (Данные->Импорт внешних данных->...).
...
Рейтинг: 0 / 0
30.06.2006, 21:01:23
    #33825382
k-nike2
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
BrowzerРылся в хелпе, там вроде как это реализуемо через назначение списку имени и функцию проверка -> список? но эксель пишет, что функция проверки для списка не работает шире чем в пределах документа.

Все правильно. В XP тоже самое.
А тот лист с именованной переменной скопировать нельзя в текущий документ, а потом на него ссылаться?

TaranagaВообщето функция проверка не работает шире чем в пределах листа.
Для именованных дипазонов работает в пределах документа.
...
Рейтинг: 0 / 0
04.07.2006, 12:05:34
    #33829700
Ivan33
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
есть еще вариант - промежуточный. сохранять значения (уникальные) в тествый файл столбцом, потом их же подгружать в другую книгу
...
Рейтинг: 0 / 0
10.07.2006, 11:25:30
    #33841528
Ivan33
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
схожая проблема

авторI have reports done in Excel sent to be by various locations every month. I'd like to combine all these reports into one large report. Is there an easy way to automate this so that I can just click a button each month for this to happen instead of cut and pasting each one into the large report? Each file has 11 columns of data with the first row being a header row.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
Sub CombineFiles() 
' Written by Barrie Davidson 
Dim Rollup_File_Name As String 
Dim File_Names As Variant 
Dim File_count As Integer 
Dim Active_File_Name As String 
Dim Counter As Integer 
Dim File_Save_Name As Variant 
    
File_Names = Application.GetOpenFilename _ 
    ("Excel Files (*.xl*), *.xl*", , , , True) 
Application.ScreenUpdating = False 
Application.DisplayAlerts = False 
File_count = UBound(File_Names) 
Counter =  1  
Workbooks.Add 
Rollup_File_Name = ActiveWorkbook.Name 
Do Until Counter > File_count 
    Active_File_Name = File_Names(Counter) 
    Workbooks.Open FileName:=Active_File_Name 
    Active_File_Name = ActiveWorkbook.Name 
    If Counter =  1  Then 
        Range("A1:K" & Range("A65536").End(xlUp).Row).Copy _ 
            Destination:=Workbooks(Rollup_File_Name). _ 
            Sheets( 1 ).Range("A1") 
    Else 
        Range("A2:K" & Range("A65536").End(xlUp).Row).Copy _ 
            Destination:=Workbooks(Rollup_File_Name). _ 
            Sheets( 1 ).Range("A65536").End(xlUp).Offset( 1 ,  0 ) 
    End If 
    Workbooks(Active_File_Name).Close False 
    Counter = Counter +  1  
Loop 
GetSaveName: 
File_Save_Name = Application.GetSaveAsFilename(, _ 
    "Excel Files (*.xls), *.xls") 
Select Case File_Save_Name 
    Case Is = False 
        MsgBox ("Please enter a file name to save the file") 
        GoTo GetSaveName 
    Case Is = "" 
        MsgBox ("Please enter a file name to save the file") 
        GoTo GetSaveName 
    Case Else 
End Select 
Workbooks(Rollup_File_Name).SaveAs FileName:=File_Save_Name 
Application.ScreenUpdating = True 
Application.DisplayAlerts = True 
End Sub 
...
Рейтинг: 0 / 0
18.07.2006, 11:17:06
    #33860024
Ivan33
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
получение значений через DAO

You can retrieve data from a Named Range in an Excel spreadsheet, without opening the spreadsheet, by using DAO. The advantages of this, compared to automating Excel, is that it is much faster, and it does not require Excel to be installed on the user's machine.

авторFirst, you need to set a reference in your project to the “Microsoft DAO 3.51 (or 3.6) Object Library”. To define a range in Excel, select the cells to be included in the range, then go Insert | Name | Define and type a name for the range. Note that the first row in the range is treated as a header row and is not retrieved.

The following example retrieves all the data from a range named “myDatabase” in an Excel file called “Book1.xls” located in folder “C:\Test\”. It then loads this data into a ListBox (ListBox1). The code is simplified by using the GetRows method. The thing to watch out for with the GetRows method is that the retrieved data array is transposed ie: the data in each record occupies one column in the array. This is evident if you use:
Код: plaintext
ListBox1.List = rs.GetRows(NoOfRecords)

авторThis is where the Column property comes in handy. If you assign the array to the Column property of the ListBox (as in the code below), the array is automatically transposed and the data appears in the correct layout in the ListBox.



Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
Private Sub UserForm_Initialize()

    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim NoOfRecords As Long

    ' Open the database
    Set db = OpenDatabase("C:\Test\Book1.xls", False, False, "Excel 8.0")

    ' Retrieve the recordset
    Set rs = db.OpenRecordset("SELECT * FROM `myDatabase`")

    ' Determine the number of retrieved records
    With rs
         .MoveLast
         NoOfRecords = .RecordCount
         .MoveFirst
    End With

    ' Set the number of Columns = number of Fields in recordset
    ListBox1.ColumnCount = rs.Fields.Count

    ' Load the ListBox with the retrieved records
    ListBox1.Column = rs.GetRows(NoOfRecords)

    ' Cleanup
    rs.Close
    db.Close

    Set rs = Nothing
    Set db = Nothing

End Sub

...
Рейтинг: 0 / 0
18.07.2006, 12:34:31
    #33860361
Ivan33
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
заполнение ячеек из списка в другой книге
вот еще вариант

авторUse the first function to read a range from a closed workbook into an
array and the second procedure for direct input into a range on the
active worksheet.

Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
'CWRIA is short for ClosedWorkbookRangeIntoArray

Function CWRIA(fPath As String, fName As String, sName As String, _
	     rng As String)
    Dim sRow As Integer
    Dim sColumn  As Integer
    Dim sRows As Integer
    Dim sColumns  As Integer
    Dim vrow As Integer
    Dim vcol  As Integer
    Dim fpStr As String
    Dim cArr()
    On Error GoTo NoArr
    If Right(fPath,  1 ) <> "\" Then fPath = fPath & "\"
    If Dir(fPath & fName) = "" Then
        CWA = CVErr(xlErrValue)
        Exit Function
    End If
    sRow = Range(rng).Row
    sColumn = Range(rng).Column
    sRows = Range(rng).Rows.Count
    sColumns = Range(rng).Columns.Count
    ReDim cArr(sRows, sColumns)
    For vrow =  1  To sRows
        For vcol =  1  To sColumns
            fpStr = "'" & fPath & "[" & fName & "]" & sName & "'!" & _
            "r" & sRow + vrow -  1  & "c" & sColumn + vcol -  1 
            cArr(vrow, vcol) = ExecuteExcel4Macro(fpStr)
        Next
    Next
    CWRIA = cArr
    Exit Function
NoArr:
    CWRIA = CVErr(xlErrValue)
End Function


'CWRIR is short for ClosedWorkbookRangeIntoArray

Sub CWRIR(fPath As String, fName As String, sName As String, _
	     rng As String, destRngUpperLeftCell As String )
    Dim sRow As Integer
    Dim sColumn  As Integer
    Dim sRows As Integer
    Dim sColumns  As Integer
    Dim vrow As Integer
    Dim vcol  As Integer
    Dim fpStr As String
    Dim cArr()
    On Error GoTo NoArr
    If Right(fPath,  1 ) <> "\" Then fPath = fPath & "\"
    If Dir(fPath & fName) = "" Then
        CWA = CVErr(xlErrValue)
        Exit Function
    End If
    sRow = Range(rng).Row
    sColumn = Range(rng).Column
    sRows = Range(rng).Rows.Count
    sColumns = Range(rng).Columns.Count
    ReDim cArr(sRows, sColumns)
    Set destRange = ActiveSheet.Range(destRngUpperLeftCell) 
    For vrow =  1  To sRows
        For vcol =  1  To sColumns
            fpStr = "'" & fPath & "[" & fName & "]" & sName & "'!" & _
            "r" & sRow + vrow -  1  & "c" & sColumn + vcol -  1 
            destRange.Offset(vrow -  1 , vcol -  1 ) = ExecuteExcel4Macro(fpStr)
        Next
    Next
NoArr:
End Sub

The following procedure copies the values from the range A1:C3 from Sheet1 of
the closed workbook cellDataVal.xls located at D:\EXCEL97\xlformulas to the
range F9:H11 on the active worksheet.   

Sub InsertRangeFromClosedWorkbook()
    CWRIR "D:\EXCEL97\xlformulas", "cellDataVal.xls", "Sheet1", _
    "a1:c3", "f9"
End Sub
...
Рейтинг: 0 / 0
Форумы / Microsoft Office [игнор отключен] [закрыт для гостей] / заполнение ячеек из списка в другой книге / 7 сообщений из 7, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]