move data within macro

88rizer

New Member
Joined
May 25, 2013
Messages
6
Hi All
I need a way to move data (if it contains the word "Memo:") up 1 and to the right 1 cell, within a macro. I am using excel 2010 on a laptop, any help will be appreiciated. Tks
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Welcome to the forum. Try this ...
Code:
Sub MoveUpRight()
For Each cl In [a1:e20] 'Change to meet your needs
    If InStr(cl.Text, "Memo:") > 0 Then
        cl.Offset(-1, 1) = cl.Text
        cl.Value = ""
    End If
Next
End Sub
 
Upvote 0
Welcome to the forum. Try this ...
Code:
Sub MoveUpRight()
For Each cl In [a1:e20] 'Change to meet your needs
    If InStr(cl.Text, "Memo:") > 0 Then
        cl.Offset(-1, 1) = cl.Text
        cl.Value = ""
    End If
Next
End Sub

Just improving on the previous answer for you ....

Code:
Sub MoveUpRight()
For Each cl In ActiveSheet.UsedRange '<< Across all used cells.
    If InStr(cl.Text, "Memo:") > 0 Then
        cl.Offset(-1, 1) = cl.Text
        cl.Value = ""
    End If
Next
End Sub
 
Upvote 0
I used BatesAC routines, I put them in a macro and accessed the macro within a control macro and it works great. Tks
 
Upvote 0
Welcome to the MrExcel board!

As a matter of interest ..

1. About how many rows and how many columns are used on your worksheet?

2. Can the "Memo:" cells be anywhere on the sheet or only in certain column(s)?
- If certain columns(s), which one(s)?

3. Can you say about how many "Memo:" cells are likely to be encountered?
 
Upvote 0
Welcome to the MrExcel board!

As a matter of interest ..

1. About how many rows and how many columns are used on your worksheet?

2. Can the "Memo:" cells be anywhere on the sheet or only in certain column(s)?
- If certain columns(s), which one(s)?

3. Can you say about how many "Memo:" cells are likely to be encountered?

Memo: is in 1 designated column and 250 rows, I am geting data from a bank acct format and changing it to fit my BankBalancing excel spreadsheet
 
Upvote 0
Memo: is in 1 designated column and 250 rows, I am geting data from a bank acct format and changing it to fit my BankBalancing excel spreadsheet
Well. that answered about 1.5 of my 4 questions ;)

However, that is enough to suggest a tidier code. Instead of checking every cell in your sheet's used range you would be better to just target those in the particular column. The particular column is one of the questions you didn't answer, so I have guessed column G. You'd need to alter that in the code to match your actual "Memo" column.

If you are using BatesAC code then I'd suggest amending the second line like this
Code:
For Each cl In Intersect(ActiveSheet.UsedRange, Columns("G"))


Edit: Actually safer would probably be
Code:
For Each cl In Range("G1", Range("G" & Rows.Count).End(xlUp))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top