Hey Guys,
Good Morning. I have probelm here.
I have 2 workbooks, 1 is Master.xls (my format to collect all the data), another 1 is Machine.xls (data collect from).
Inside Master.Range("B3:B5") have a data (etc: Line1, Line2, Line3), Machine.xls have a few sheets (etc: Line1, Line2, Line3....Line10).
Now my concern is I want the macro loop Master.Range("B3:B5") , if Master.Range = Line1 then it will loop Machine.xls untill found the sheets name is Line1 then collect data from it. It will loop Master.Range("B3:B5") untill equal to blank.
Thanks for your advice.
2 4466
with a couple of IFS/THEN/ELSE and FOR/NEXT it can be done. To make reference to the workbooks, you can use their name or their index (the order they were open)
Check this little example: - If workbooks("myBook1").worksheets("sheet1).range("B1") = workbooks("myBook2").worksheets("sheet1).range("B1") then
-
workbooks("myBook1").worksheets("sheet2).range("A4") = "Hello World"
-
else
-
workbooks("myBook2").worksheets("sheet2).range("C4") = "Goodbye Cruel World"
-
end if
You can use Indexes or CELLS to put anything into a loop, eg: - for i = 1 to 5
-
workbooks("myBook1").worksheets(i) = "Hello World"
-
next
and you can always check the content or use the END method to go to the blank space, eg: - i=1
-
do
-
i=i+1
-
loop until cells(i,1) = ""
HTH
with a couple of IFS/THEN/ELSE and FOR/NEXT it can be done. To make reference to the workbooks, you can use their name or their index (the order they were open)
Check this little example: - If workbooks("myBook1").worksheets("sheet1).range("B1") = workbooks("myBook2").worksheets("sheet1).range("B1") then
-
workbooks("myBook1").worksheets("sheet2).range("A4") = "Hello World"
-
else
-
workbooks("myBook2").worksheets("sheet2).range("C4") = "Goodbye Cruel World"
-
end if
You can use Indexes or CELLS to put anything into a loop, eg: - for i = 1 to 5
-
workbooks("myBook1").worksheets(i) = "Hello World"
-
next
and you can always check the content or use the END method to go to the blank space, eg: - i=1
-
do
-
i=i+1
-
loop until cells(i,1) = ""
HTH
Thanks kadghar,
Its make me many confusing because to many For, Do, Loop.... but I have done it. Have a nice day.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: pmud |
last post by:
Hi,
I need to use an Excel Sheet in ASP.NET application so that the users can
enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever
the USER ENETRS needs to go to the...
|
by: RickH |
last post by:
..Cells(1,y).GetType ownly shows instead of .Value, .Copy, etc.
The code below is derived from samples, it should work, but I've messed up
somewhere...
Imports System.Windows.Forms
Imports...
|
by: implicate_order |
last post by:
Greetings,
I'm new to python and am in the process of writing a script to parse
some CSV data, spread it across multiple Excel worksheets and then
generate charts. I searched the internet to...
|
by: bbasberg |
last post by:
Hello,
I have been struggling with this problem for DAYS and have googled my heart out as well as reading any books I could get my hands on but I cannot find any specific references to my problem....
|
by: keithsimpson3973 |
last post by:
Hi. I am trying build an array in vb applications for excel. I am posting the code for what I am trying to write. Any help would be appreciated greatly..
Sheets("C16-M-001").Select
...
|
by: Anish G |
last post by:
Hi All,
I am getting the below given error while running my application in live server. In my local machine, its working fine. Please help me as it is very urgent for me.
Exception from...
|
by: =?Utf-8?B?Um9iZXJ0?= |
last post by:
I am opening an Excel Workbook from C# (VS2005) and I need to get a value
from a Spreadsheet before closing the C# application. Does anyone know if
this can be done? Here is the code to open the...
|
by: acarrazco |
last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined...
|
by: TARHEELS721 |
last post by:
I am trying to send the results of a query that runs when I click a button on my form that is based on a parameter query. The code runs without any errors but nothing is exported into my excel...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |