Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 03-03-2015, 10:55 AM
grexcelman grexcelman is offline For Next Loop cell values Windows 7 32bit For Next Loop cell values Office 2003
Novice
For Next Loop cell values
 
Join Date: Dec 2014
Posts: 21
grexcelman is on a distinguished road
Default

Quote:
Originally Posted by excelledsoftware View Post
I know this is an older post but I cant help but want to help.

I would write what you are doing slightly different but I know it works this way.

Code:
Sub CompareData()
  'Looks at a range and compares it another
  Dim CheckRow As Integer, ws As Worksheet
  
  Set ws = ThisWorkbook.Worksheets("Sheet1")
  
  For CheckRow = 1 To 10
    If ws.Range("A" & CheckRow).Value = ws.Range("F" & CheckRow).Value Then
      'Do whatever you want to do here.
      'Example 1 ws.range("G" & CheckRow).value = "They Match"
    Else
      'Do whatever you want if they dont match or just remove this to say
      'End if
    End If
  Next CheckRow
  
End Sub
This was great. Thanks for replying! I appreciate it as I kept trying to find workarounds for my problem but nothing quite worked as efficiently as I wanted. Your solution should help me. One question, whats the best way to change the sheet name in the 'set ws' line so that I can apply this code on separate sheets?
Reply With Quote
 

Tags
loop, range



Similar Threads
Thread Thread Starter Forum Replies Last Post
For Next Loop cell values Convert non-cell input to cell values TBD Excel 3 06-09-2014 06:14 AM
For Next Loop cell values Sum values within a single cell shabbaranks Excel 17 05-13-2014 06:47 PM
How do you loop through an array with some empty values? omahadivision Excel Programming 5 11-28-2013 10:49 AM
change values based on cell ubns Excel 1 05-21-2012 06:28 PM
For Next Loop cell values Automatic, Dependent Cell Values flackend Excel 2 08-26-2011 07:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft