我有大约50个复选框,它们都链接到它们所在的单元格(例如A2中的复选框链接到单元格A2)。我的循环工作到一定程度。 我遇到的问题是选择链接的单元格并将偏移量设置为1个单元格,然后复制该行,而不是链接的单元格。 然后粘贴到不同的工作表到下一个空白行。
Sub CheckboxLoop()
Dim objx As OLEObject
Dim lastrow As Range
Application.ScreenUpdating = False
'Loop through Checkboxes
With ActiveSheet
For Each objx In .OLEObjects
If TypeName(objx.Object) = "CheckBox" Then
If objx.Object.Value = True Then
If objx.Object.LinkedCell = True Then 'runtime error 438 object doesn't support this property or method
objx.Object.LinkedCell.Offset(0, 1).Select
Range(Cells(Selection.Row, 1), Cells(Selection.Row, 3)).Select
Selection.Copy
Worksheet("Data").Select
Worksheet("Data").Range("A1").End(xlDown).Offset(1, 0).Select
Selection.PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End If
ElseIf objx.Object.Value = False Then
ElseIf IsNull(objx.Object.Value) Then
End If
End If
Next
End With
Application.ScreenUpdating = True
End Sub
当我单步执行宏时,一切正常,直到我到达第3个,如果我收到运行时错误438对象不支持此属性或方法
任何帮助都会很棒,谢谢
答案 0 :(得分:1)
public class MaterialPaletteAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<Item> data;
private RecyclerViewOnItemClickListener recyclerViewOnItemClickListener;
private static final int TYPE_COLOR = 0;
private static final int TYPE_FOOTER = 1;
public MaterialPaletteAdapter(@NonNull List<Item> data, RecyclerViewOnItemClickListener recyclerViewOnItemClickListener) {
this.data = data;
this.recyclerViewOnItemClickListener = recyclerViewOnItemClickListener;
}
@Override
public int getItemViewType(int position) {
if (data.get(position) instanceof TaskRow) {
return TYPE_COLOR;
} else if (data.get(position) instanceof Footer) {
return TYPE_FOOTER;
} else {
throw new RuntimeException("ItemViewType unknown");
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == TYPE_COLOR) {
View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
PaletteViewHolder pvh = new PaletteViewHolder(row, recyclerViewOnItemClickListener);
return pvh;
} else {
View row = LayoutInflater.from(parent.getContext()).inflate(R.layout.progress_footer, parent, false);
FooterViewHolder vh = new FooterViewHolder(row);
return vh;
}
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof PaletteViewHolder) {
TaskRow taskRow = (TaskRow) data.get(position);
PaletteViewHolder paletteViewHolder = (PaletteViewHolder) holder;
String myString = taskRow.getPicture();
try {
JSONArray arr = new JSONArray(myString);
byte[] myArray = new byte[myString.length()];
for (int k = 0; k < arr.length(); k++) {
myArray[k] = (byte) arr.getInt(k);
}
Bitmap bmp = BitmapFactory.decodeByteArray(myArray, 0, myArray.length);
paletteViewHolder.profilepic.setImageBitmap(bmp);//small user picture
} catch (JSONException e) {
e.printStackTrace();
}
paletteViewHolder.tvpostby.setText(taskRow.getFirstname() + " " + taskRow.getLastname());
String ackwardRipOff = taskRow.getPostdate().replace("/Date(", "").replace(")/", "");
long time = Long.parseLong(ackwardRipOff);
Date d= new Date(time);
paletteViewHolder.tvdatetime.setText(new SimpleDateFormat("dd-MMM-yyyy h:mm a").format(d));
paletteViewHolder.tvlocation.setText(taskRow.getCityname());
if(taskRow.getPosttypeid().equals("2") || taskRow.getPosttypeid().equals("4"))
{
String myString1 = taskRow.getImagefull();
try {
JSONArray arr = new JSONArray(myString1);
byte[] myArray = new byte[myString1.length()];
for (int k = 0; k < arr.length(); k++) {
myArray[k] = (byte) arr.getInt(k);
}
final Bitmap bmp1 = BitmapFactory.decodeByteArray(myArray, 0, myArray.length);
paletteViewHolder.imgpost.setImageBitmap(bmp1);//post picture
paletteViewHolder.imgpost.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp1.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
// Intent i=new Intent(getContext(), ImageFull.class);
// i.putExtra("Image",byteArray);
// getContext().startActivity(i);
}
});
} catch (JSONException e) {
e.printStackTrace();
}
paletteViewHolder.imgpost.setVisibility(View.VISIBLE);
}
paletteViewHolder.tvpost_text.setText(taskRow.getPostcontent());
}
}
@Override
public int getItemCount() {
return data.size();
}
public static class PaletteViewHolder extends RecyclerView.ViewHolder
implements View.OnClickListener {
public ImageView profilepic;
public TextView tvpostby;
public TextView tvdatetime;
public TextView tvlocation;
public TextView tvpost_text;
public ImageView imgpost;
public TextView tvlike;
public TextView tvlikelable;
public TextView tvcommentlable;
public TextView tvsharelable;
private RecyclerViewOnItemClickListener recyclerViewOnItemClickListener;
public PaletteViewHolder(View itemView, RecyclerViewOnItemClickListener recyclerViewOnItemClickListener) {
super(itemView);
profilepic=(ImageView)itemView.findViewById(R.id.profile_pic);
tvpostby=(TextView)itemView.findViewById(R.id.tv_postby);
tvdatetime=(TextView)itemView.findViewById(R.id.tv_date_time);
tvlocation=(TextView)itemView.findViewById(R.id.tv_location);
tvpost_text=(TextView)itemView.findViewById(R.id.tvpost_text);
imgpost=(ImageView)itemView.findViewById(R.id.img_post);
tvlike=(TextView)itemView.findViewById(R.id.tv_like);
tvlikelable=(TextView)itemView.findViewById(R.id.tv_like_lable);
tvcommentlable=(TextView)itemView.findViewById(R.id.tv_comment);
tvsharelable=(TextView)itemView.findViewById(R.id.tv_share);
imgpost.setVisibility(itemView.GONE);
this.recyclerViewOnItemClickListener = recyclerViewOnItemClickListener;
itemView.setOnClickListener(this);
}
@Override
public void onClick(View v) {
recyclerViewOnItemClickListener.onClick(v, getAdapterPosition());
}
}
public static class FooterViewHolder extends RecyclerView.ViewHolder {
public ProgressBar getProgressBar() {
return progressBar;
}
private ProgressBar progressBar;
public FooterViewHolder(View itemView) {
super(itemView);
progressBar = (ProgressBar) itemView.findViewById(R.id.footer);
}
}
}
属性为LinkedCell
类型,并存储/检索链接到组合框的单元格的地址
所以你要使用
String