|
I am trying to format different spreadsheets. I need the data to be in the same cells for each worksheet. This data is in column A. I need to check to see if DBCS# (?) is above Tour, and if so insert rows until Tour is in row 175, column A. The problem is that the number after DBCS# is never the same. How can I use an IF statement to make sure that the cell above Tour says DBCS# (whatever the number is)? This is the If statement that I tried. If I put DBCS#46 in my IF statement, it will not work because the number after # isn't always 46.
If (Range("A174:A174") = "DBCS#") And (Range("A175:A175") = "TOUR") Then GoTo label_177: Else: Do While (Range("A174:A174") <> "DBCS#") And (Range("A175:A175") <> "TOUR") Selection.EntireRow.Insert Loop End If
Example:
| DBCS #33 | | Help Nikki | Hello, maybe this will help Try If (Left(Range("A174:A174") ,5)= "DBCS#") And (Range("A175:A175") = "TOUR") Then GoTo label_177: | | blackmamba | | Thanks. I tried that and the program is still not working correctly. | | Help TW | hmm, Try Left(Cstr(Range...),5) Also, is there a blank space between DBCS and # ? then you have to use left(string, 6).
| | blackmamba | | I tried that also and it is still not working. There are no spaces between DBCS, #, and the number. | | Help TW | Sorry, do you get a syntax error or the code loops infinitely ? Cause i think the code after else is not the right one.
| | blackmamba | One more thing, use Cstr(Range(...)) to compare it with a string....
| | blackmamba | | That worked. Thank you so very much. | | Help TW | |