Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-08-2017, 01:17 PM
Radtastic10 Radtastic10 is offline Multiple Problems with a loop Windows 7 64bit Multiple Problems with a loop Office 2010 64bit
Novice
Multiple Problems with a loop
 
Join Date: Jun 2017
Posts: 5
Radtastic10 is on a distinguished road
Default Multiple Problems with a loop


I am currently having a problem with this loop.

Code:
 last_col = 1
 Do Until IsEmpty(Cells(last_col, 1))
    tempstr = ActiveSheet.Range(last_col & First_row).Value
    If InStr(tempstr, "(Apple)") > 0 Then
       str = Split(last_col & First_row, "(")
       ActiveSheet.Range(last_col & First_row).Value = str & "Red Apple"
    End If
    last_col = last_col + 1
  Loop
It is getting hung up when I try to store the value of the current cell in a temporary string. The goal of the loop is to go through the row of column titles and check if the substring is contained in that cell then switch it to the new title. However, it does not store anything in the temporary string when stepping through the loop.
Reply With Quote
  #2  
Old 06-08-2017, 05:23 PM
NoSparks NoSparks is offline Multiple Problems with a loop Windows 7 64bit Multiple Problems with a loop Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Try using Cells, as you do in the IsEmpty line, rather than Range
Reply With Quote
  #3  
Old 06-09-2017, 09:20 AM
Radtastic10 Radtastic10 is offline Multiple Problems with a loop Windows 7 64bit Multiple Problems with a loop Office 2010 64bit
Novice
Multiple Problems with a loop
 
Join Date: Jun 2017
Posts: 5
Radtastic10 is on a distinguished road
Default

Quote:
Originally Posted by NoSparks View Post
Try using Cells, as you do in the IsEmpty line, rather than Range
I Just tried this and no luck. I appreciate the idea though; that had never even crossed my mind.

The incrimination portion of the loop works great. The only real problem as of now is getting the title of each column to save to the temporary string.
Reply With Quote
  #4  
Old 06-09-2017, 09:38 AM
Radtastic10 Radtastic10 is offline Multiple Problems with a loop Windows 7 64bit Multiple Problems with a loop Office 2010 64bit
Novice
Multiple Problems with a loop
 
Join Date: Jun 2017
Posts: 5
Radtastic10 is on a distinguished road
Default

Figured out the problem. On the
Code:
tempstr = ActiveSheet.Cells(last_col, First_row).Value
The last_col and First_row needed to be flipped and have First_row, last col. I it was looking in row 1 column whatever instead of column 1 row whatever.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Problems with a loop Macro Loop Help Twizzle008 Word VBA 15 09-18-2015 03:20 PM
Multiple Problems with a loop Loop - Row increment jrt Excel Programming 1 04-16-2015 01:46 PM
Multiple Problems with a loop Having Problems with Multiple Keys sorengg Mail Merge 5 03-14-2013 10:06 PM
Multiple Problems with a loop How to a For loop in VBA Jennifer Murphy Word VBA 1 01-29-2013 03:30 AM
While loop not working right Cbrehm Excel Programming 0 05-11-2011 11:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:44 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