+ Reply to Thread
Results 1 to 2 of 2

Get right cell macro

Hybrid View

  1. #1
    Registered User
    Join Date
    07-08-2013
    Location
    Brazil
    MS-Off Ver
    Excel 2010, 2013
    Posts
    1

    Exclamation Get right cell macro

    Hello everyone,

    Im new to this forum and new to excel as well, im very bad at visual basic, but a good programmer. I Kept my whole week working on a macro to get some information from another excel file, thats my situation: I got lots of excel files with lots of information on different cells (i.e.: file1 has name on cell B10, but file2 has the name on cell B39), and i need to pull all the information and organize it on another file. I gotta get all the names, ages, and addressess of the people and put in a separate excel file (I guess a separate workbook). My problem is that i dont know exaclty how to get the information from different cells, since i dont know how to find, select and pull the information. The tables are organized this way:

    | B10 | C10 |
    |Name | John |
    |Age | 39 |
    |Address | 5th Avenue |

    I can find and grab the information on the cell "Name", but i want the information on the right cell, not the one i found...

    I tried this code, but it doesnt seem to work:

    Sub ImportarDados()
    Dim Pasta As String
    Dim Arquivo As String
    Dim i As Integer
    Dim row As Integer

    i = 3
    row = 1
    Pasta = "C:\CSV\"
    Arquivo = Dir(Pasta & "*.xlsx")
    Do
    While Len(Range("A" & CStr(row)).Value) > 0

    If Range("E" & CStr(row)).Value = "Name" Then

    Workbooks.Open (Pasta & Arquivo)

    ThisWorkbook.Sheets("Plan1").Cells(i, 2).Value = [E348].Value

    ActiveWorkbook.Close False

    End If

    LSearchRow = LSearchRow + 1

    Wend

    i = i + 1
    Arquivo = Dir
    Loop While Arquivo <> ""
    End Sub


    Anyway, does anyone knows a way to do that? i already though on grep + awk on linux, but i wanted to try a macro before going to linux..

    Thanks in advance.

    Jean Douglas Conte

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Get right cell macro

    Do the offset method.

    
    rangeIFound.offset(<rows>, <cols>).value = whatever

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1