Thread: [Solved] For Next Loop cell values
View Single Post
 
Old 03-03-2015, 02:56 PM
excelledsoftware excelledsoftware is offline Windows 7 64bit Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

Pretty easy to do actually. Make sure to dim your other worksheets and give them a variable name such as ws and ws1. I will typically use ws for the worksheet that has the data and then rws for the worksheet that gets the results. When you set something you are telling Excel that you want to reference an object. This is different than setting a string = "Your Name Here" which you would do like so.
Code:
TestString = "Your Name Here"
To set a worksheet that is named Data and another worksheet that is named Results refer to the following example.
Code:
  Dim ws as Worksheet, rws as Worksheet

  Set ws = ThisWorkbook.Worksheets("Data")
  Set rws = ThisWorkbook.Worksheets("Results")
You can of course set a variable as a workbook so you dont have to type in ThisWorkbook all the time. This code below should serve as a great reference.

Code:
   Dim ws as Worksheet, rws as Worksheet, wb as Workbook

  Set wb = ThisWorkbook
  Set ws = wb.Worksheets("Data")
  Set rws = wb.Worksheets("Results")
Let me know if you have any other questions.

Thanks
Reply With Quote